Latest stories

Install ZeroMQ on Mac with PHP PECL extension

Getting ZeroMQ working on a Mac looks like a pain if you try to compile, but there’s a much easier way to get it up and running, with just a few brew and PECL commands. I’ve been wary of Homebrew for a while, as there were lots of issues with Macports in the past, but I’ve found it’s a lot easier than trying to compile various things yourself in OS X (I tried to compile...

Create diff patch from Composer /vendor to apply to Git repository

If you’ve accidentally made changes to a package in the /vendor directory of your project, you’ll need to apply these same changes to the Git repository that the package comes from (or fork it and patch it, etc.) before Composer overwrites the updates. The easiest way to do this is to create a diff patch which you can then apply to the package repository. You need to make sure...

Late Static Binding namespace resolution in PHP

If you try to get the namespace of the child class that you are in using the __NAMESPACE__ keyword, you will have the same problem that you do using functions like get_class() in that you will get the namespace (or class) where the current method you are calling is defined. $namespace = __NAMESPACE__; $class = get_class(); You can use get_called_class() to resolve this for Late Static Binding...

Capistrano website deployment with PHP Composer

Composer is great for handling PHP dependencies, and Capistrano is great for automated deployment, so wouldn’t it be great if you could use them together? To do this, all you need to do is update your recipe with the following task, then add a hook to make it run when the recipe is used. To add the hook, make sure that Composer is triggered after finalize_update (which means it will happen...

Disable auto-correct for oh-my-zsh when using Chef Knife (or other commands)

oh-my-zsh is great, but certain commands it doesn’t like, for example the Knife CLI tool for Chef. Luckily it is possible to disable auto-correct as required. sudo vim ~/.zshrc To disable just auto-correction for Knife, add the following line somewhere in the configuration nocorrect knife To disable all auto-correct (which I prefer personally) add the following line somewhere in the...

Output CSV straight to browser using PHP

If you want a user to download a CSV, but do not want to have to generate it on the filesystem first, you can output the CSV directly to the browser by writing it to PHP’s output stream. If you set the resource for the normal PHP CSV functions as the PHP output stream you can use output buffering to then save it into a string. You can then output this straight to the browser along with the...

Install Yahoo YUI compressor on Mac OS X, use in terminal

Since there are seemingly no simple guides on how to simply install the YUI compressor on Mac, or how to use it in the terminal (command line) as Yahoo’s instructions are useless, and most other guides show how to use it integrated into a website as an on-the-fly processor; if you’d prefer to compress your assets prior to deployment as opposed to on-the-fly then you’ll need to...

PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/module.so’

For some reason (I think just on Red Hat/CentOS) you may end up with a bad reference in mcrypt.ini so “module.so” as opposed to “mcrypt.so” To update this simply edit mcrypt.ini so that it points to the right extension (instead of what I’m assuming is placeholder text) vim /etc/php.d/mcrypt.ini You should see the following… ; Enable mcrypt extension module...

Concrete5 “Fatal error: Class ‘View’ not found”

Concrete5 may present you with the confusing error “Fatal error: Class ‘View’ not found”, which looks like a Loader issue but often it is not. When moving between different servers, the database permissions may not be quite right, which will cause this to happen. If you check that the user that Concrete5 is using has access to the database and the correct credentials, then...

“Could not open configuration file /usr/local/zend/etc/sites.d/zend-default-vhost-80.conf”

If you’ve upgraded from an older version of Zend Server than 5.6 up to 6.0 you may have ended up with a patched httpd.conf that references a vhost configuration file that has not been created. If you try to start Apache you may see this message: $ sudo apachectl start httpd: Syntax error on line 428 of \ /usr/local/zend/apache2/conf/httpd.conf: \ Could not open configuration file \...