Broken PHP Configuration on OSX Mavericks
For some unfound reason PHPUnit, which was working with my previous OSX install, had broken. I updated to the brand new OSX Mavericks and it killed my setup local development environment, the configuration all reverted. It was showing me the following error:
$ phpunit -c app/ PHP Warning: require(/usr/lib/php/pear/PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 43 PHP Fatal error: require(): Failed opening required '/usr/lib/php/pear/PHPUnit/Autoload.php' (include_path='.:') in /usr/bin/phpunit on line 43
When looking at the error that was throw the first problem to correct was the Include Path, which is listed in the php.ini as ::
include_path='.:' – there was nothing specified to locate the PHPUnit files for
Find the location of the PEAR files.
pear config-get php_dir
Error with PEAR
Could not open input file: /usr/lib/php/pear/pearcmd.php
Yes, PEAR was not working. So first thing is to get it up and running again.
sudo /usr/bin/php /usr/lib/php/install-pear-nozlib.phar
Once installed it is suggested from the successful install message we add the PEAR path to the php.ini include path. My installed location was
We shall update PEAR before updating the php.ini.
sudo pear channel-update pear.php.net sudo pecl channel-update pecl.php.net sudo pear upgrade --force pear sudo pear upgrade sudo pecl upgrade
Set the php.ini file
When I run the command:
php -i | grep Configuration
It shows that there is no configuration file set.
Configuration File (php.ini) Path => /etc Loaded Configuration File => (none) Configuration cd /etc cp php.ini.default php.ini
Make sure that the date.timezone is set in the php.ini configuration.
Update the ini File
Make sure the correct
php.ini file is edited.
php -i | grep Configuration Configuration File (php.ini) Path => /etc Loaded Configuration File => /private/etc/php.ini Configuration
Open the Loaded Configuration File and find the line that specifies the include_path. The base install looks like:
; Original - ;include_path = ".:/php/includes"
Remove the “;” and update the include path:
include_path = ".:/usr/lib/php/pear" sudo apachectl restart
Now that PEAR is sorted, running
pear version will show the version number, we can move on PHPUnit.
phpunit -v PHP Warning: require(/usr/lib/php/pear/PHPUnit/Autoload.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 43 PHP Fatal error: require(): Failed opening required '/usr/lib/php/pear/PHPUnit/Autoload.php' (include_path='.:/usr/lib/php/pear') in /usr/bin/phpunit on line 43
The error is much the same, but our
include_path has been updated.
sudo pear config-set auto_discover 1 sudo pear channel-discover pear.phpunit.de sudo pear channel-discover components.ez.no sudo pear channel-discover pear.symfony-project.com sudo pear install phpunit/PHPUnit phpunit -v PHPUnit 3.6.12 by Sebastian Bergmann.
Back in business again.