Getting PEAR and PHPUnit to work with MAMP

When I recently decided to start re-developing a PHP project of mine from scratch, I decided to replace SimpleTest with PHPUnit and PHPCover.

To get familiar with PEAR, I found this great tutorial:

However, since I managed to screw up my PEAR configurations when playing around with it a month ago, the tutorial did not work.

Turns out that PEAR was missing from where I wanted it to be installed, and that multiple PEAR installations were scattered all over the file system. The config file pointed to one of these locations, which made the installer believe that I had the latest release installed.

Turns out that:

Finally, I could follow the tutorial at the top of this post. Installing PHPUnit was a breeze after the invalid PEAR settings were fixed.

You also need to grab PHPCover, which is described at

Now, you have to set the include paths in /etc/php.ini. Mine looks like this:

  • include_path=”.:/php/includes:/usr/lib/php:/usr/lib/php/pear

However, since I use MAMP, this is not the file that is to be. You need to modify the ini file in MAMP’s configuration area, and add the paths there as well.

Now, PHPUnit will work, but I am yet to be convinced. SimpleTest seems easier to setup and flexible enough to cover all test cases I need, including mocking…plus that I can ship the testing framework with the development bundle.

Any thoughts regarding this?