Last Updated: 21 Nov 2020
Installing PHPUnit on MAMP
- MAMP, as you may know, has its own versions of PHP, PEAR, etc. These aren't related to the versions that Apple provides with OS X. MAMP's copies of these binaries live at
/Applications/MAMP/bin/php/php5.2.17/bin. You'll want to install your PHPUnit there.
- For some reason, there's an old config file that MAMP chokes on. At least there was on my install:
mv /Applications/MAMP/bin/php/php5.2.17/conf/pear.conf /Applications/MAMP/bin/php/php5.2.17/conf/pear.conf.bak
- First, you'll probably need to update PEAR:
/Applications/MAMP/bin/php/php5.2.17/bin/pear channel-update pear.php.net /Applications/MAMP/bin/php/php5.2.17/bin/pear upgrade pear
This should upgrade you to PEAR 1.9.4, or possibly a newer version.
- Now it's time to add the appropriate PEAR channels for PHPUnit:
/Applications/MAMP/bin/php/php5.2.17/bin/pear channel-discover pear.phpunit.de /Applications/MAMP/bin/php/php5.2.17/bin/pear channel-discover pear.symfony.com /Applications/MAMP/bin/php/php5.2.17/bin/pear channel-discover components.ez.no
- Finally, install PHPUnit:
/Applications/MAMP/bin/php/php5.2.17/bin/pear install phpunit/PHPUnit
- Test phpunit to make sure it was installed correctly:
- Technically, you're done now. However, its a real pain to access PHPunit by typing its full path, so I like to symlink it to
phpunitin my path:
sudo ln -s /Applications/MAMP/bin/php/php5.2.17/bin/phpunit /usr/local/bin/phpunit
That's it! If you have any questions or suggestions for improvements, post in the comments.