Latest stories

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 \...

How to safely handle PHP “__toString() must not throw an exception”

Because there is no safe way to handle an exception thrown during __toString the easiest workaround for this is to catch all exceptions thrown and return either an empty string or null.
Since any invocation of __toString will expect a string back, it is a graceful way to handle any under-the-hood errors if you’re using __toString as a shortcut to echo out objects.

What does vagrant up do, where does the box get downloaded to?

Vagrant is a pretty nifty tool that simplifies developing on a Virtual Machine. However it is sometimes not obvious what happens in the background! An example of this is where your VM’s actually get downloaded to, and how they are managed. Since Vagrant acts as a wrapper for VirtualBox (or VMWare Fusion more recently) when you “add” a box, it essentially downloads a pre-built...

Convert non-Java Eclipse ADT project to Android project

If you’ve imported a project into Eclipse, say from Git for example, then it might not be set as an Android project. There doesn’t seem to be an easy way to convert the project to an Android project through Eclipse itself, but you can change the nature of the project by editing the project XML file. Close the project in Eclipse Open .project in a text editor Assuming...