kikukawa's diary

都内で活動するシステムエンジニアが書いてます。 興味を持った技術やハマったポイント、自分用メモをつけてます。 最近はweb中心

composerのインストール時のdetect_unicode

-bash-4.1$  curl -sS https://getcomposer.org/installer | php
#!/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

The php.ini used by your command-line PHP is: /usr/local/php/lib/php.ini
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.

composerを使うには、detect_unicodeをOFFに設定するのが必須のようです。
メッセージの通り、php.iniを確認したところ、OFFになっていませんでした。
何らかの理由でphp.iniの編集ができない場合、

php -d option=value

という形式で、phpを実行すれば問題ないようです。
ただし、この方法を取ると、インストール以降もcomposerコマンドを使用するときは、常に-dオプションが必要になるので、可能ならばphp.iniを修正したほうが良いと思います。

改めてインストールしたらうまくいきました。

-bash-4.1$  curl -sS https://getcomposer.org/installer | php -d detect_unicode=false
#!/usr/bin/env php
Some settings on your machine may cause stability issues with Composer.
If you encounter issues, try to change the following:

PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.
Recompile it without this flag if possible

Downloading...

Composer successfully installed to: /path/to/composer.phar
Use it: php composer.phar

initやinstallコマンドでも下記のように指定します。

php -d detect_unicode=false composer.phar init
php -d detect_unicode=false composer.phar install