[php]composer self-updateでエラー[required for SSL/TLS protection]が出るときの対処法

PHPでcomposerのアップデートを行った時、opensslのライブラリでSSL/TLS protectionエラーが出る場合があります。※下記の例の”composer self-update”は、windowsの場合は環境によって”php.exe composer.phar self-update”になる場合もあります。

> php.exe composer.phar self-update

[RuntimeException] 
The openssl extension is required for SSL/TLS protection 
but is not available. 

If you can not enable the openssl extension, 
you can disable this error, at your own risk, 
by setting the 'disable-tls' option to true.

このエラーに対して一時的にSSLのチェックを外したい場合は、下記のコマンドでdisable-tlsのフラグを立てればOKです。

composer config --global -- disable-tls true

上記のコマンドを実行すると、下記のフォルダに設定内容が登録されます
(configの場所はcomposer config --list -vvvでverbose出力すれば確認できます)

C:\Users\ユーザ名\AppData\Roaming\Composer\config.json

設定内容がconfigにセットされているかは、下記のコマンドで確認できます。

composer config --list

関連記事

コメントを残す

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