- 使用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
修改後composer.json 文件
{ "repositories": { "packagist": { "type": "composer", "url": "https://packagist.phpcomposer.com" } } }