Saturday, August 13, 2011

PEAR not installed by default on Snow Leopard and later

In OSX Snow Leopard and later pear isn't installed by default. The installer is already available to you though.

sudo php /usr/lib/php/install-pear-nozlib.phar
pear config-set php_ini /private/etc/php.ini
pecl config-set php_ini /private/etc/php.ini
sudo pear upgrade-all

If you're using php for the first time on osx you may also need to copy this config file into existance.
(normally I'd use vim but to not explain vim we're using nano here)
sudo nano /private/etc/apache2/httpd.conf
Delete the # from the line that reads:
#LoadModule php5_module libexec/apache2/

cd /private/etc
sudo cp php.ini.default php.ini

And since you're already messing with PEAR, we really should take full advantage of this opportunity to install PHPUnit.

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

If you have issues running phpunit a common cause is a misconfigured php.ini where the include path needs to be updated to:

include_path = ".:/usr/lib/php:/usr/lib/php/pear"

No comments:

Post a Comment