PHPUnit and PEAR install on MacOS

PHPUnit and PEAR install on MacOS
Page content

There is a plenty of tutorials how to install PEAR and  PHP, but there is always something “missing” in this configuration. So this time, i’m going to “sing the same song again”.

Let’s start – PEAR

curl http://pear.php.net/go-pear.phar > go-pear.phar
sudo php -d detect_unicode=0 go-pear.phar

Make sure that you have setup similar to this one (may vary about you current setup):

1. Installation base ($prefix) : /usr/lib/php
2. Temporary directory for processing : /tmp/pear/install
3. Temporary directory for downloads : /tmp/pear/install
4. Binaries directory : /usr/bin
5. PHP code directory ($php_dir) : /usr/lib/php
6. Documentation directory : /usr/lib/php/doc
7. Data directory : /usr/lib/php/data
8. User-modifiable configuration files directory : /usr/lib/php/cfg
9. Public Web Files directory : /usr/lib/php/htdocs
10. Tests directory : /usr/lib/php/tests
11. Name of configuration file : /Users/sjas/.pearrc

Very important part of the process is to properly setup includes path in php.ini, by defualt there is no /etc/php.ini, so you have to create / copy it.:

sudo cp /etc/php.ini.default /etc/php.ini
sudo nano /etc/php.ini

and make sure that you have something like that:

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

PHPUnit

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
pear install -a -f pear.phpunit.de/FinderFacade

XDebug for Mac OS

ode.activestate.com/komodo/remotedebugging

Bonus tip how to install older version of Pear package:

pear uninstall PHP_CodeSniffer
pear installl PHP_CodeSniffer-1.4.8