November 11, 2011
To install PHPUnit, there are two direct dependencies which first need to be installed;
As Xdebug also depends on PEAR, we’ll make sure that’s installed first.
My source-compiled version of PHP is installed at
/usr/local/php, so we’ll first jump into that directory;
$ cd /usr/local/php
Now, following the instructions for Installing PEAR, I opted to download the installation script and run it locally;
$ wget -c http://pear.php.net/go-pear $ ./bin/php go-pear
All the default settings should be fine, so go ahead and finish installing PEAR.
As per the Installation Instructions, stay in the same directory and run the following;
./bin/pecl install xdebug
Again, follow the installation through to the end, and it should have installed the xdebug.so library into the libs/extensions directory. On my machine, it put it at
/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so (don’t ask me why…) Now, we have to add this module to PHP by editing the php.ini file. Fire up your favourite text editor, point it to
/usr/local/php/lib/php.ini and add the following line;
Restart (or start) your server (I’m using apache installed at
/usr/local/apache2, so I did
$ /usr/local/apache2/bin/apachectl -k restart). Get a phpinfo() call, and you should have both “PEAR” and “Xdebug” listed on the page. So far, so good.
From PHPUnit’s manual, run the following commands;
$ ./bin/pear channel-discover pear.phpunit.de $ ./bin/pear channel-discover components.ez.no $ ./bin/pear channel-discover pear.symfony-project.com $ ./bin/pear install phpunit/PHPUnit
For some reason this one took quite a while (1 minute) to begin, but once it did, it went quick and installed PHPUnit to
/usr/local/php/PEAR/PHPUnit. Et voilà. Start writing tests for PHPUnit!