Thursday, 8 March 2012

Install PHPUnit in MAMP

To install PHPUnit in MAMP 2.0.5, run the following commands in Terminal, noting that the pear.conf file needs to be deleted first. Also, ignore the premature word-wrapping in the commands as they should be one line each.

rm /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf

/Applications/MAMP/bin/php/php5.3.6/bin/pear channel-update

/Applications/MAMP/bin/php/php5.3.6/bin/pear upgrade pear

/Applications/MAMP/bin/php/php5.3.6/bin/pear channel-discover

/Applications/MAMP/bin/php/php5.3.6/bin/pear channel-discover

/Applications/MAMP/bin/php/php5.3.6/bin/pear install phpunit/PHPUnit 

To test this, you can run the following in Terminal:
/Applications/MAMP/bin/php/php5.3.6/bin/phpunit --version

Caution: before performing the next step, make sure that you won't be conflicting with another installation of PHPUnit!

To run php unit with the command "phpunit", you can make a symlink to the phpunit binary in a directory that is defined in your PATH, such as /usr/local/bin, e.g.:

sudo ln -s /Applications/MAMP/bin/php/php5.3.6/bin/phpunit /usr/local/bin/phpunit

No comments:

Post a Comment