[PHP]composerのインストールでUnable to find the wrapper “https”エラー

PHPでcomposerをインストールしようとしたとき、以下のようにUnable to find the wrapper "https"エラーが出る場合があります。

>php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
Warning: copy(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in Command line code on line 1
Warning: copy(https://getcomposer.org/installer): failed to open stream: No such file or directory in Command line code on line 1

この理由として、php.iniでhttpsが実行できない設定になっている可能性があります。

対処法は、php.iniを開きphp_opensslのextensionがコメントアウトされている場合は、コメントを外してください。
php.ini自体がない場合は、php.ini-developmentをコピーしてphp.iniを作ります。

#extension=php_openssl.* 
↓
extension=php_openssl.* 

また、phpのインストールディレクトリをデフォルトの位置(windowsだとc:\php)から変更している場合は、上記に加えてextension_dirの設定も必要になる場合があります。

; extension_dir = "ext"
↓
extension_dir = "C:\path\to\php\php-7.1.3\ext"

関連記事

コメントを残す

メールアドレスが公開されることはありません。