Getting PEAR and PHPUnit to work with MAMP

Sep 15, 2011 · Follow on Twitter and Mastodon archive

When I recently decided to start re-creating 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 while playing around with it a while back, the tutorial didn’t work.

Turns out that PEAR was missing from where it should 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:

  • I had managed to set a different install path, due to this.
  • PEAR was always downloaded to my user root.
  • I had to delete all PEAR installations.
  • I also had to delete the config file.

I could then follow the tutorial at the top of this post. Installing PHPUnit was a breeze after the invalid PEAR settings were fixed. However, you also need to get PHPCover, which is described here.

You also have to set the include paths in /etc/php.ini. Mine looks like this:


However, since I use MAMP, I also neededed to modify this file in MAMP’s config area and add the paths there as well.

PHPUnit now works, but yet now convinced. SimpleTest seems easier to setup and flexible enough to cover all test cases I need, including mocking. It also makes it possible to ship the testing framework with the dev bundle.

Time will tell if I decide to go with PHPUnit or stick with SimpleTest.

Discussions & More

Please share any ideas, feedback or comments you may have in the Disqus section below, or by replying on Twitter or Mastodon..

If you found this text interesting, make sure to follow me on Twitter and Mastodon for more content like this, and to be notified when new content is published.

If you like & want to support my work, please consider sponsoring me on GitHub Sponsors.