I use MAMP on my Mac daily for most of my web development. It’s a nice sandbox’ed environment but also very easy to maintain. MOST of the libs that I need are pre-bundled with MAMP, but sometime its required that I need something thats not pre-bundled.
Here’s how to configure PEAR to work properly with MAMP on the Mac, so you can use it via the command line to add PEAR stuffs.
Configuring PEAR under MAMP
First open up terminal and make sure that you’re PATH is set to use the correct pear binary, that being the pear in the MAMP directory. If you don’t want to alter your pear path, you can manually call the pear binary. Anywhere you see “pear somethingoranother” below, just replace it with /Applications/MAMP/bin/php5.2/bin/pear somethingoranother” or cd into that bin dir and use “./pear somethingoranother”.
Also note: some older versions of MAMP did not have 2 versions of PHP installed, so take that into consideration. Newer versions have 2 php folders, and 2 builds of pear and other libs. I generally still use PHP5.2 daily, so thats what I’ll reference.
### # setup the php5.2 vars for the mamp pear # !! it is ASSUMED that before these are run, the users PATH is # updated to use /Applications/MAMP/bin/php5.2/bin/pear before /usr/local/pear !! # in your ~/.profile or ~/.bash_profile or somewhere... ### # MAMP binaries should override others for Apache, PHP and MySQL export PATH=/Applications/MAMP/bin/php5\.2/bin:/Applications/MAMP/bin/apache2/bin:/Applications/MAMP/bin:$PATH
Update the MAMP PEAR Configs to reference the proper files.
IMPORTANT: the extensions folder may be different for you, double the ACTUAL name of the no-debug-… folder first.
pear config-set bin_dir /Applications/MAMP/bin/php5.2/bin pear config-set doc_dir /Applications/MAMP/bin/php5.2/lib/php/doc pear config-set ext_dir /Applications/MAMP/bin/php5.2/lib/php/extensions/no-debug-non-zts-20050922 pear config-set php_dir /Applications/MAMP/bin/php5.2/lib/php pear config-set data_dir /Applications/MAMP/bin/php5.2/lib/php/data pear config-set php_bin /Applications/MAMP/bin/php5.2/bin/php pear config-set test_dir /Applications/MAMP/bin/php5.2/lib/php/test pear config-set sig_keydir /Applications/MAMP/conf/php5.2/pearkeys ### # these were already set, but may need to be set manually still (if not already pointing to the correct place) ### pear config-set Filename /Applications/MAMP/conf/php5.2/pear.conf pear config-set www_dir /Applications/MAMP/bin/php5.2/lib/php/www pear config-set cfg_dir /Applications/MAMP/bin/php5.2/lib/php/cfg
That should be it!
Install PHPUnit
Just to test it out, here’s what I was able to do to get PHPUnit installed. You SHOULD see the files installed in /Applications/MAMP/bin/php5.2/lib/php, e.g. after this you should see /Applications/MAMP/bin/php5.2/lib/php/PHPUnit exist.
### # Install phpunit/PHPUnit with PEAR (a bit of a test run) ### # need this first (not "stable" yet) pear install channel://pear.php.net/Net_URL2-0.3.1 # need this second (not "stable" yet) pear install channel://pear.php.net/HTTP_Request2-2.0.0RC1 # make sure channels are added pear channel-discover pear.phpunit.de pear channel-discover components.ez.no pear channel-discover pear.symfony-project.com # finally, install phpunit/PHPUnit with non-stable dependancies fulfilled pear install phpunit/PHPUnit
One Comment
Thank you it really saved my day. Best regards.