Installing PHPUnit with MAMP’s PEAR installer is pretty straightforward, but there are a few things to note:

  1. Everything will be done through Terminal, so go ahead and launch it now. All of the commands I give can be copied and pasted as they are.
  2. Make sure you’re using the version of PEAR that came with MAMP, not the version that came with your Mac. This means we have to use /Applications/MAMP/bin/php5/bin/pear at the prompt, not pear.
  3. PHPUnit 3.4 requires PHP 5.1.4 or later, but PHP 5.3.2 or later is recommended. MAMP 1.8.2 (the version I have installed) is running version 5.2.10. The latest version of MAMP includes version 5.3.2. So far, I haven’t noticed any problems running PHPUnit under 5.2.10.
  4. PHPUnit also requires PEAR 1.8.1. MAMP 1.8.2 ships with version 1.8.0. To check which version you have installed, type
    /Applications/MAMP/bin/php5/bin/pear -V.

If you need to upgrade PEAR, first use the following two commands:
/Applications/MAMP/bin/php5/bin/pear channel-update pear.php.net
/Applications/MAMP/bin/php5/bin/pear upgrade pear

Now, it’s time to install PHPUnit. The PEAR channel used to distribute PHPUnit needs to be registered with the local PEAR environment, and a component that PHPUnit depends upon is hosted on the Symfony Components PEAR channel. To register the channels and install, simply type:
/Applications/MAMP/bin/php5/bin/pear channel-discover pear.phpunit.de
/Applications/MAMP/bin/php5/bin/pear channel-discover pear.symfony-project.com
/Applications/MAMP/bin/php5/bin/pear install phpunit/PHPUnit

PHPUnit is now installed, but to get it to run from Terminal, we need to move it into our $PATH. To do so, type:
mv /Applications/MAMP/bin/php5/bin/phpunit /usr/local/bin/phpunit.

To test your install, type:
phpunit --version.

You should see something like PHPUnit 3.4.15 by Sebastian Bergmann. And that's it!

In my last post, I described how to install the Fileinfo PECL module on a Media Temple (dv) server, but I didn't really talk about what it does, why one might want to install it and how to use it.

The methods/functions in the Fileinfo PHP extension "try to guess the content type and encoding of a file by looking for certain magic byte sequences at specific positions within the file. While this is not a bullet proof approach, the heuristics used do a very good job."1 (Note that this module replaces the Mimetype module.)

Read the rest of this entry »