Installing PHPUnit under PHP 5.4 from Homebrew

On my mac, I use Jose Gonzales’ homebrew tap for installing PHP 5.4. It works amazingly well, generating apache modules and FPM plists for every version in case I need them, as well as the CLI version.

Unfortunately, it also means that all of you pear extensions are installed under your PHP 5.4 install, meaning that you have to do a bit of work to get it all working. Here are the steps I followed:

Install PHPUnit

sudo pear channel-discover
sudo pear channel-discover
sudo pear install --alldeps phpunit/phpunit

Configure your PHP include path

Edit your php.ini to set up your include path, it’s normally at /usr/local/etc/php/5.4/php.ini (or run php -i to see).

Search for include_path and add the path /usr/local/Cellar/php54/5.4.7/lib/php/. It should look something like this:


Note that you might need to change 5.4.7 to whatever version of PHP you have installed. Run php -v to find out.


Open a new terminal window and type phpunit - things should be working fine

November 17, 2012

Quick Fix