After my laptop has been running really for a couple of weeks now, I have decided to order some new RAM and do a clean install of Lion. This has given me a great opportunity to configure my development environment in a cleaner and more organised way.
As a developer I do install a number of packages to play around with and then either decide its not for me or find there was a better way configuring them and then find myself in a bit of a muddle.
One tool I have been playing with recently is Composer which is a dependency manager, think Ruby Gems but for PHP. Which is a great little tool and I’m really happy to see the community getting behind it and moving forward. After just trying to install composer I ran into a little problem which I thought was worth sharing.
After running curl -s https://getcomposer.org/installer | php, I get the following error:
Some settings on your machine make Composer unable to work properly. Make sure that you fix the issues listed below and run this script again: The detect_unicode setting must be disabled. Add the following to the end of your `php.ini`: detect_unicode = Off
Which looks pretty simple to fix but MAMP should have this setting disabled. So I ran which php and I’m told I’m running /usr/bin/php which is the version of PHP that comes preinstalled with OS X. So we just need to swap this over to the PHP that is installed with MAMP, which is located at /Applications/MAMP/bin/php/php5.4.4/bin (MAMP 2.1.1).
To do this I edit my .bash_profile or .profile if you are using a different shell and add the MAMP version of PHP to the PATH variable.
It’s important to append the existing $PATH at the end otherwise the version of PHP in /usr/bin/php will be found and loaded first instead. Save the .bash_profile and reload your profile by typing source ~/.bash_profile and run which php, and if you’ve done everything right should say /Applications/MAMP/bin/php/php5.4.4/bin/php.
Note: Tom has pointed out in the comments that in MAMP 2.1.1 You are unable to run MAMP’s PHP from the command line so you will need to update MAMP first.