composer: 通过 socks5 proxy 更新报错


执行的命令及全部报错信息:


 $ composer update ## 想更新 Yii 2 的 basic-template ##
Loading composer repositories with package information
The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Unable to find the socket transport "socks5" - did you forget to enable it when you configured PHP?
https://packagist.org could not be fully loaded, package information was loaded from the local cache and may be out of date
Updating dependencies (including require-dev)
The "https://bower.herokuapp.com/packages/jquery" file could not be downloaded: failed to open stream: Unable to find the socket transport "socks5" - did you forget to enable it when you configured PHP?
https://bower.herokuapp.com/packages could not be fully loaded, package information was loaded from the local cache and may be out of date
Nothing to install or update
Generating autoload files

本地机器 linux, 设置了代理:


 export http_proxy='socks5://127.0.0.1:1080'
export https_proxy='socks5://127.0.0.1:1080'

看报错信息是要对php进行设置, 遍寻网络找不到答案.

然后, 查看了下console 下的php设置


 $ echo "<?php phpinfo(); " | php | grep socks
http_proxy => socks5://127.0.0.1:1080
https_proxy => socks5://127.0.0.1:1080
_SERVER["http_proxy"] => socks5://127.0.0.1:1080
_SERVER["https_proxy"] => socks5://127.0.0.1:1080

还有 composer的设置


 cat ~/.composer/config.json  
{
    "config": {
    }
}

也尝试了 更改以下变量的值(0|1)


 export HTTPS_PROXY_REQUEST_FULLURI
export HTTP_PROXY_REQUEST_FULLURI

补充1:


 $ export http_proxy='socks:127.0.0.1'
$ export https_proxy='socks:127.0.0.1'
$ composer update

部分报错信息:


 The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Unable to find the socket transport "socks" - did you forget to enable it when you configured PHP?

谢谢!

composer php socks5

Nukaman 9 years, 11 months ago

http_proxy 你用socks

我叫舒书好 answered 9 years, 11 months ago

Your Answer