如何更正作曲家的 [Composer\Downloader\TransportException] 错误

2022-08-30 22:32:34

好日子的人,我已经遇到这个问题好几天了,当我尝试使用作曲家下载我的php项目的依赖项时,我得到这个错误

c:\wamp64\www\Test>composer global require "fxp/composer-asset-plugin:^1.3.1"
Changed current directory to C:/Users/Nwachukwu Favour/AppData/Roaming/Composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Installation failed, reverting ./composer.json to its original content.


  [Composer\Downloader\TransportException]
  The "http://packagist.org/p/provider-2014%241cf88bd0ed4076dc091407477ba2a76483e8598ee5365673381262e6c1d40fcf.jso
  n" file could not be downloaded: failed to open stream: HTTP request failed!


require [--dev] [--prefer-source] [--prefer-dist] [--no-plugins] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] [<packages>]...

我正在运行Windows 10操作系统,并怀疑我的系统无法从命令行下载。如果有人能帮助我解决这个问题,我会非常高兴,因为它阻碍了我的项目。提前致谢。


答案 1

您还可以在安装任何依赖项之前在 CLI 上运行此命令。它强制作曲家使用https下载所有资源:

composer config -g repo.packagist composer https://packagist.org

答案 2

此问题可能是由从 http 重定向到 https 引起的。(或您的防火墙阻止呼叫)

根据本文,可以通过将以下内容添加到您的 composer.json 中来解决此问题:

"repositories": [
    {
         "type": "composer", 
         "url": "https://packagist.org"
    },
    { "packagist": false }
]

强制作曲家使用与 Packagist 的 https 连接


推荐