composer The openssl extension is required for SSL/TLS

更新composer 异常,或安装某个包时

The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl exension, you can disable this error, at your own risk, by setting the 'disable-tls' option to true.

这段异常日志的大致意思是,Composer采用SSL连接,需要外挂OpenSSL插件。

启用OpenSSL。安装了PHP后,编辑php.ini,通过修改配置文件来启用OpenSSL插件。

编辑php.ini文件,首先,定位到:

...
;extension=php_mysqli.dll
extension=php_openssl.dll
...

删除extension=php_openssl.dll前面的分号,取消注释,从而启用OpenSSL插件。

注意:因为SSL连接需要认证,所以继续下面的步骤之前,需要准备好CA证书,可以从https://curl.haxx.se/docs/caextract.html处下载。

接下来,定位到

;openssl.cafile= 

和上面一样,删去分号,取消注释,设置CA证书为openssl.cafile= E:\phpstudy\cacert.pem

最后, 重新在命令行窗口中打开项目的根目录,执行命令:composer install,等待几分钟后,就可以成功添加monolog依赖。

猜你喜欢

转载自blog.csdn.net/wan271920545/article/details/88110463