Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer cannot download files

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?

like image 984
mlwacosmos Avatar asked Mar 07 '13 09:03

mlwacosmos


People also ask

How do I check my composer memory limit?

You have to provide the full path in order to run it. Running which composer will tell you where the OS finds the composer executable, and then you simply use the full path in the PHP command: $>which composer /usr/local/bin/composer $>php -d memory_limit=512M /usr/local/bin/composer update ...

Why is composer not installing?

Make sure you have no problems with your setup by running the installer's checks via curl -sS https://getcomposer.org/installer | php -- --check . Try clearing Composer's cache by running composer clear-cache . Ensure you're installing vendors straight from your composer.

What is composer phar?

Composer is a dependency management tool for PHP projects. It allows you to declare the libraries your project requires and installs/updates them for you. It is deployed as a PHAR (PHP Archive) file. Phar is already enabled by default on your DreamHost server.


2 Answers

The right an easy way to run composer on windows under a proxy is opening the console (cmd), go to your project location and run this command:

C:\wamp\htdocs\myproject\> SET HTTP_PROXY=http://username:[email protected]:8080 && php composer.phar install

PD: You must changes parameters like: username, password, proxy.yourdomain.com and 8080 to yours

I hope this help to you

like image 31
Oriam Avatar answered Nov 12 '22 02:11

Oriam


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
like image 131
Tim Groeneveld Avatar answered Nov 12 '22 02:11

Tim Groeneveld