Tag: PHP

Overloading constructors and functions in PHP

Since I was recently asked whether it’s possible to overload constructors in PHP, or functions in general, here is the quick answer: No, not in the common sense of “overloading”, i.e. creating multiple versions of the same function name with different implementations and arguments. Thus, the following is not possible by default in PHP: Pattern-based […]

Enabling Cross-Origin Resource Sharing CORS for PHP

This post is an addition to Enabling Cross-Origin Resource Sharing CORS for Apache to show you how to enable Cross-Origin Resource Sharing CORS for PHP. Thus, in case you don’t have access to the .htaccess you can simply enable CORS for PHP using the following steps. Setting required headers using PHP As explained in Enabling […]

Magento Error ESI processing not enabled

In a recent Magento setup with a Varnish caching server an undefined PHP variable in a template resulted in the error message “ESI processing not enabled“. Due to the undefined PHP variable the underlying Varnish caching server’s Edge-side includes (ESI) capabilities, allowing content assembly by HTTP surrogates through in-markup XML-based language failed. After a quick […]

Web-based KeePass(X) Management Tool

KeePass and KeePassX are almost perfect tools when it comes to storing passwords and other sensitive information. Almost, since these tools currently only work offline and do not expose command line options out of the box. Since I want to access certain information on the road I was searching for ways to access KeePass and […]

PHP Continuous Integration ServerPHP Continuous Integration Server

Continuous integration for PHP projects oftentimes exist of merely running your latest test cases against PHPUnit and on success uploading your new file versions to your staging (or even production) server. Although Jenkins is able to handle all those tasks (easily) the way along numerous configuration steps can be quite painful. With PHPCI a new […]

Multilanguage support in Silverstripe

Operating interational websites and portals naturally requires multilanguage support and localization. Especially more prominent frameworks provide i18n support right out of the box. One of these is Silverstripe which recently has been released in version 3. This brief article describes the steps required to activate multilanguage support in Silverstripe. First of all, you need to […]

Shortening Strings (URLs) using Base 62 Encoding

Today, there already exist numerous URL shortening services, such as tinyurl, bit.ly, qr.cx and many more. Although they are very handy when it comes to shortening URLs in blog posts and articles oftentimes they can’t be used in proprietary software due to certain copyright and usage restrictions. Thus, a vast range of projects have evolved […]

Mehrseitige Formulare mittels Zend Framework umsetzenImplementing multi-page forms using the Zend Framework

Unfortunately, the Zend Framework (ZF) version 1.x currently does not provide a standard way or class to implement multi-page forms based on Zend_Form. Due to the fact that this is a very common use case I will try to explain a working solution to overcome this problem. Basically, the goal is to provide means to […]

Delete/copy directories recursively using PHP

As there currently does not exist a PHP function that allows developers to delete or copy entire (non-empty) directories at once one has to recursively loop through them to manually delete/copy their contents. This post provides you with two easy to use functions for deleting entire (non-empty) directories copying entire (non-empty) directories First, let’s start […]

Calculate next auto-increment value for MySQL tables

Sometimes it is necessary to determine the next auto-increment value that will be used by MySQL for inserting values into tables. First off, there are several different approaches to determine it. Most people use the MAX() function and simply add 1 to the value. Although this is fine is most cases, you may run into […]

Assigning PHP variables in shell

For a project I am currently working on it was necessary to read PHP define()’d-values from a configuration file using a shell script that did some further processing. In order to be able to read define()’d-values you need to first include() (or better require_once()) the source configuration file(s) and then assign its values to shell […]