Composer无法下载文件 [英] Composer cannot download files
问题描述
我想在命令行上使用composer:
I am trying to use composer on command line :
php composer.phar update
php composer.phar install
php composer.phar self-update
php composer.phar selfupdate
无论我做什么,我总是收到相同的错误消息:
Whatever I do I always receive the same error message:
无法下载文件。无法打开流
File could not be downloaded. Failed to open stream
我在代理后面。如果我使用浏览器并输入与不使用命令行的URL相同的URL,则没有问题。
I am behind a proxy. If I use a browser and type the same URLs as the ones that didn't work with command line, there is no problem.
我该怎么办?
推荐答案
如果您在HTTP代理后面使用composer,可以使用标准 http_proxy
或 HTTP_PROXY
env vars。只需将其设置为您的代理的URL。许多操作系统已为您设置此变量。
If you are using composer from behind an HTTP proxy, you can use the standard http_proxy
or HTTP_PROXY
env vars. Simply set it to the URL of your proxy. Many operating systems already set this variable for you.
例如:
HTTP_PROXY="http://my-corp-proxy.mcdonalds" php composer.phar install
为了方便起见,您只需导出变量即可,如果你在Linux / OS X或Windows环境设置中将它放到bashrc中,那么您不必一直输入。
To make it easier, you can just export the variable, then you don't have to type it all the time.
export HTTP_PROXY="http://my-corp-proxy.mcdonalds"
php composer.phar install
这篇关于Composer无法下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!