使用composer引了一个包出现如下异常
[Composer\Downloader\TransportException] Your configuration does not allow connection to http://packagist.phpcomposer.com. See https://getcomposer.org/doc/06-config.md#secure-http for details.
看了下phpcomposer
secure-http Defaults to true. If set to true only HTTPS URLs are allowed to be downloaded via Composer. If you really absolutely need HTTP access to something then you can disable it, but using Let's Encrypt to get a free SSL certificate is generally a better alternative.
要么改secure-http配置,要么把composer地址从http改成https
解决方法1:
把默认的 secure-http 改成false
composer config -g secure-http false
解决方法2:修改配置文件
#修改全局文件(推荐) composer config -g repo.packagist composer https://packagist.phpcomposer.com
#修改当前配置文件 composer config repo.packagist composer https://packagist.phpcomposer.com
方法3
composer self-update
修改后composer.json 文件
{ "repositories": { "packagist": { "type": "composer", "url": "https://packagist.phpcomposer.com" } } }
在使用Composer安装包时遇到因secure-http配置导致的异常。解决方案包括:将secure-http设置为false,或修改composer配置文件以使用HTTPS。此外,还可以尝试更新Composer自身。通过修改composer.json文件,确保使用安全的HTTPS连接到包仓库。
571

被折叠的 条评论
为什么被折叠?



