Installing PHP Composer on Mac OS X and how to solve detect_unicode error

The easiest way that I have found to install PHP Composer is following next commands:

1) Go to your directory where you want to install PHP Composer, for example I want to install PHP Composer in the next directory (this will allow install Laravel Framework, but the same applies for any other purpose).

cd /Applications/XAMPP/htdocs/laravel

2) Try to install PHP composer executing the next line:

curl -s http://getcomposer.org/installer | php

Now, if when you execute this command an error like this appears (take it easy, we can solve it, jejeje):

#!/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.

3) In order to solve the detect_unicode error, please just add a parameter to your command as the next line shows:

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

4) That’s it! Now, be happy with a message like this:

All settings correct for using Composer
Downloading...

Composer successfully installed to: /Applications/XAMPP/xamppfiles/htdocs/laravel/composer.phar
Use it: php composer.phar

See you the next time, my friend!

Alex Arriaga

 

2 comments on “Installing PHP Composer on Mac OS X and how to solve detect_unicode error”

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

    Some settings on your machine may cause stability issues with Composer.
    If you encounter issues, try to change the following:

    The OpenSSL library (0.9.8y) used by PHP does not support TLSv1.2 or TLSv1.1.
    If possible you should upgrade OpenSSL to version 1.0.1 or above.

    can you please tell me the easy way for openssl update but without brew

Leave a Reply to Zamani

Your email address will not be published. Required fields are marked *