composer错误: Composer\Downloader\TransportException

 [Composer\Downloader\TransportException]
  The "http://packagist.org/packages.json" file could not be downloaded: failed to open stream: HTTP request failed!

create-project [-s|--stability="..."] [--prefer-source] [--prefer-dist] [--repository-url="..."] [--dev] [--no-dev] [--n
o-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--keep-vcs] [--no-install] [--ignore-platform-reqs]
[package] [directory] [version]

Workaround Disable https requests, use http way. So we set up a local or global configuration of the composer in composer.json config file

Method One: command-line composer config secure-http false. Command modifying composer.json, the effect of two equivalent methods.

Method two: direct change composer.json, to "config" add item "secure-http": false 

"config" : {  
        "vendor-dir" : "packages",
        "secure-http": false  
}

 

Global configuration (recommended)

config the -l -g Composer 
// switch to a domestic source Ali
Composer config -g repo.packagist Composer https://mirrors.aliyun.com/composer/
Composer config -g --unset repos.packagist

 

Guess you like

Origin www.cnblogs.com/mzhaox/p/11239363.html