Using Composer PHP (and Git) behind a Proxy in Windows

We said good-bye to the PEAR packages, and hello to Composer. All is working fine at my home computer, but then I go to work and try to make Composer work without any luck. So, what happened?

After installing Composer (wihtout any error I might add…), whenever I try to use it to work on a PHP project, or to install one of the popular frameworks (which, by the way, can only be installed with Composer if you want to have the files up to date and easy project management…), I get an error like this:

The … file could not be downloaded: failed t
o open stream: A connection attempt failed because the connected party did
not properly respond after a period of time, or established connection fail
ed because connected host has failed to respond.

That happened to me because I was behind a proxy server. After much looking into the problem, and trying everything, including RTFM about the proxy setting in Windows (https://getcomposer.org/doc/03-cli.md#http-proxy-or-http-proxy), nothing seemed to work.

Nothing but this…

Composer PHP

1. Using the command prompt, go to the folder where you want to install the project, framework, packagist packet, github project, or whatever you want to install with Composer.

2. Set the proxy by writing: SET HTTP_PROXY=xxx.xxx.xxx.xxx (where xxx is your proxy).

3. Use composer as you usually use it from command prompt.

Git

1. If you have git installed in your system PATH, write in command prompt: git config –global http.proxy xxx.xxx.xxx.xxx

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

No spam? * Time limit is exhausted. Please reload CAPTCHA.