Mountain Lion php pear and pecl

ianckc picture ianckc · Aug 11, 2012 · Viewed 11.5k times · Source

I've upgraded to Mountain Lion and installed php5.4 which took a bit of tweaking Mountain Lion change php location

My next issue is if I run pear -v or pecl -v these return

Could not open input file: /usr/lib/php/pear/pearcmd.php

Could not open input file: /usr/lib/php/pear/peclcmd.php

Do I need to change pear and pecl to point to my new php which is installed in /usr/local/php5/bin/

If so how do I do this and will I lose all of my previously installed extensions such as phpunit?

Thanks

Answer

ianckc picture ianckc · Aug 12, 2012

I sorted this by installing pear again. After downloading go-pear.phar then running

sudo php -d detect_unicode=0 go-pear.phar

In the install there are options to change directories pear is using. They were already set to the correct locations for my new php such as /usr/local/php5/bin

I then had to add that path to my bash_profile for the pear command to be recognised.

export PATH=$PATH:/usr/local/php5/bin

To get pecl working again I removed pecl from /usr/bin then symlinked to the pecl in /usr/local/php5/bin

sudo ln -s /usr/local/php5/bin/pecl /usr/bin/pecl

The first package I tried to install was APC and I got the error

Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

ERROR: `phpize' failed

This was sorted by following instructions from phpize won't work on Mac OS X Lion I used the homebrew solution

UPDATE: I installed PHPUnit fine then ran phpunit --version

This gave an error of

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

Running which phpunit returned /usr/bin/phpunit

Solved by more symlinking

sudo ln -s /usr/local/php5/bin/phpunit phpunit