Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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.

What should I do?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
231 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.

eg:

 HTTP_PROXY="http://my-corp-proxy.mcdonalds" php composer.phar install

bonus points if you throw it into your bashrc if your on Linux/OS X or your environment settings for Windows.

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...