composer 常见问题
D:\phpStudy>composer require phpoffice/phpspreadsheet [Composer\Exception\NoSslException] The openssl extension is required for SSL/TLS protection but is not availab le. 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连接、直接“裸奔”;二是启用OpenSSL
1.放弃SSL连接
① composer config -g -- disable-tls true
# 然而出现了另外的问题:
[Composer\Downloader\TransportException]
Your configuration does not allow connections to http://packagist.org/packages.json. See https://getcomposer.org/doc/06-config.md#secure-http for details.
② composer config -g secure-http false #所以需要再次进行设置,禁用SSL
这种方法本人未测试
2.启用OpenSSL
打开php.ini 配置文件
extension=php_openssl.dll # 取得前面的分号注射从而启用OpenSSL插件 openssl.cafile="你下载的证书路径" #绝对路径 删去前面分号,取消注释,
注意:因为SSL连接需要认证,所以继续下面的步骤之前,需要准备好CA证书,CA证书下载地址: https://curl.haxx.se/docs/caextract.html,最后重启服务即可。
[Composer\Downloader\TransportException] Your configuration does not allow connections to http://packagist.org/packages.json. See https://getcomposer.org/doc/06-config.md#secure-http for details.
解决方法禁用https请求,改用http方式
方法一:
设置一个本地或全局的composer配置:
composer config secure-http false
全局设置:
composer config -g secure-http false
通过命令修改composer.json,效果等同方法二。
方法二:
直接改composer.json,给“config”项中加上"secure-http": false
"config" : {
"vendor-dir" : "packages",
"secure-http": false
}
相关文章:

浙公网安备 33010602011771号