This will look much easier than it was, because I spent considerable time finding the easiest way not just “a way” to install PHPUnit on XAMPP with a Mac OS X (10.7.4).
- Open terminal. The key I found out after some trial and error is do NOT use the pear install that comes with your Mac. Instead when you call a pear command you need to call it with the full path to the pear install that comes with XAMPP. Something like this…
/Applications/XAMPP/xamppfiles/bin/pear
(To see if this pear command works simply put that above line (as is) into your Terminal prompt, and you should return a list of available pear commands.)
- Now that we have pear tested and we’re using the right pear. We need to run a few simple commands to upgrade pear and install PHPUnit.
sudo /Applications/XAMPP/xamppfiles/bin/pear upgrade PEAR
sudo /Applications/XAMPP/xamppfiles/bin/pear config-set auto_discover 1
sudo /Applications/XAMPP/xamppfiles/bin/pear install pear.phpunit.de/PHPUnit
Now, that wasn’t so hard. Too bad it took most of the day to figure out that you can’t use just a “sudo pear” command.

This was super helpful thanks!