PHP Composer behind http proxy
If you're on Linux or Unix (including OS X), you should put this somewhere that will affect your environment:
export HTTP_PROXY_REQUEST_FULLURI=0 # or false
export HTTPS_PROXY_REQUEST_FULLURI=0 #
You can put it in /etc/profile
to globally affect all users on the machine, or your own ~/.bashrc
or ~/.zshrc
, depending on which shell you use.
If you're on Windows, open the Environment Variables control panel, and add either a system or user environment variables with both HTTP_PROXY_REQUEST_FULLURI
and HTTPS_PROXY_REQUEST_FULLURI
set to 0
or false
.
For other people reading this (not you, since you said you have these set up), make sure HTTP_PROXY
and HTTPS_PROXY
are set to the correct proxy, using the same methods. If you're on Unix/Linux/OS X, setting both upper and lowercase versions of the variable name is the most complete approach, as some things use only the lowercase version, and IIRC some use the upper case. (I'm often using a sort of hybrid environment, Cygwin on Windows, and I know for me it was important to have both, but pure Unix/Linux environments might be able to get away with just lowercase.)
If you still can't get things working after you've done all this, and you're sure you have the correct proxy address set, then look into whether your company is using a Microsoft proxy server. If so, you probably need to install Cntlm as a child proxy to connect between Composer (etc.) and the Microsoft proxy server. Google CNTLM for more information and directions on how to set it up.
Can't install Composer on Ubuntu behind proxy
I got help from some experts close by:
add 3 lines to /etc/profile
export http_proxy=http://[username]:[password]@[webproxy]:[port]
export https_proxy=http://[username]:[password]@[webproxy]:[port]
export ftp_proxy=http://[username]:[password]@[webproxy]:[port]
For a similar error (apt-get update was not reaching some repositories), I edited /etc/apt/apt.conf:
Acquire::http::proxy "http://[username]:[password]@[webproxy]:[port]";
Acquire::https::proxy "https://[username]:[password]@[webproxy]:[port]";
Acquire::ftp::proxy "ftp://[username]:[password]@[webproxy]:[port]";
take care to remove the "/" after the port number (it was already there).
Now it's all working.
Composer cannot download files
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
Related Topics
PHP Regex Delimiter, What's the Point
Parse JSON String Contents into PHP Array
Echo Menu Tree with Recursive Function
Clean Links to PHP-Generated JavaScript and CSS
Hide Variable Product Dropdown That Has a Unique Variation Selected by Default in Woocommerce
Which Tokens Can Be Parameterized in Pdo Prepared Statements
How to Populate Dependable Drop-Down Using Ajax and PHP
How to Decode Eval( Gzinflate( Base64_Decode(
How to Fix the "Base Table or View Not Found: 1146" Error When Running 'PHP Artisan Migrate' Command
Why Doesn't Var_Dump Work with Domdocument Objects, While Print($Dom->Savehtml()) Does
PHP Regular Expression to Match Lines Starting with a Special Character
Target Class Does Not Exist. Problem in Laravel 8