Composer Downloader TransportException 解决方法

  • 使用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" } } }

猜你喜欢

转载自blog.csdn.net/u012460314/article/details/100585105
今日推荐