无法运行composer安装



我正试图在我的项目中运行composer安装,但我遇到了以下错误

[ComposerDownloaderTransportException]
The "http://packagist.org/p/provider-2013$43e3f41fbe30a46245103451248f688a727f076a6e90636d19a69a156c17a416.json" file could not be downloaded (HTTP/1.1 400 Received invalid request from Client)

我已经尝试运行composer自我更新,并出现此错误

[ComposerDownloaderTransportException]
The "https://getcomposer.org/version" file could not be downloaded: Failed to enable crypto failed to open stream: operation failed

我在代理服务器后面运行Ubuntu 15.04和apache/php5.6.4/mysql。

我已尝试下载http://curl.haxx.se/ca/cacert.pem并用以下更新了我的php.ini文件

curl.cainfo=/etc/ssl/certs/cacert.pem
openssl.cafile=/etc/ssl/certs/cacert.pem
openssl.capath=/etc/ssl/certs

运行composer diagnose返回此

Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: FAIL
[ComposerDownloaderTransportException] The "http://packagist.org/packages.json" file could not be downloaded (HTTP/1.1 400 Received invalid request from Client)
Checking https connectivity to packagist: OK
Checking HTTP proxy: OK
Checking HTTP proxy support for request_fulluri: FAIL
Unable to assess the situation, maybe packagist.org is down (The "http://packagist.org/packages.json" file could not be downloaded (HTTP/1.1 400 Received invalid request from Client))
Checking HTTPS proxy support for request_fulluri: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking composer version: FAIL
You are not running the latest version

最后openssl_get_cert_locations((返回

  • 默认证书文件:/usr/lib/ssl/cert.pem
  • default_cert_file_env:SSL_cert_file
  • default_cert_dir:/usr/lib/ssl/certs
  • default_cert_dir_env:SSL_cert_dir
  • default_private_dir:/usr/lib/ssl/private
  • default_default_cert_area:/usr/lib/ssl
  • ini_cafile:/etc/ssl/certs/cachert.pem
  • ini_capath:/etc/ssl/certs

我完全不知道出了什么问题,更不知道如何调试它。

我希望有人能帮助我!

与您相同。我在互联网上找到了解决问题的方法(适用于windows 10(。1-转到文件夹PATHxamppapache并运行makecert.bat2-将此脚本添加到composer.json文件

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

这个问题很可能与某种HTTPS强制有关,因为从上面的composer diagnose来看,HTTP连接测试失败,而HTTPS测试通过:

Checking HTTP connectivity to packagist: FAIL
...
Checking HTTP proxy support for request_fulluri: FAIL
...
Checking HTTPS proxy support for request_fulluri: OK

运行以下代码段(在composer上强制HTTPS(为我解决了问题:

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

解决方案源

如果你是Linux(Ubuntu(用户,那么执行以下命令来解决:

php -r "print_r(openssl_get_cert_locations());"
wget http://curl.haxx.se/ca/cacert.pem
sudo mv cacert.pem /usr/lib/ssl/certs/cert.pem // Note: Create the cert.pem file under certs folder if does not exist.

也许您可以尝试更改代理。

http://composer-proxy.jp/

这是来自日本的代理人。希望它对你有用。

尝试php composer global self-update

在环境中设置代理,在终端中使用:

export http_proxy=<proxy>:<port>
export https_proxy=<proxy>:<port>

如果linux服务iptables停止

或关闭Windows 上的防病毒、防火墙

如果以上内容都不适用,请尝试删除系统设置的http_proxy环境变量"环境变量";

尝试composer全局自更新1.4.1

相关内容

  • 没有找到相关文章

最新更新