/ Web Development

PHP Composer on OS X Mountain Lion

OS X 10.8 has PHP 5.3 installed with CLI support by default, so there isn’t any extra installation needed for Composer, a dependency manager for PHP, to be installed globally on a Mac. However, trying to install it via the guides results in an error.

#!/usr/bin/env php
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

A php.ini file does not exist. You will have to create one.
If you can not modify the ini file, you can also run `php -d option=value` to modify ini values on the fly. You can use -d multiple times.

To get around the error, just install with the -d flag as stated in the error.

curl -s getcomposer.org/installer | php -d detect_unicode=Off

Then, just add it to the system path. I choose to move it where homebrew applications are installed.

mv composer.phar /usr/local/bin/composer

Now Composer is installed.