How to correct the [Composer\Downloader\TransportException] error for composer

Viewed 50589

Good day people, I have been having this problem for days now, when I try to download dependencies for my php project using composer I get this error

c:\wamp64\www\Test>composer global require "fxp/composer-asset-plugin:^1.3.1"
Changed current directory to C:/Users/Nwachukwu Favour/AppData/Roaming/Composer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Installation failed, reverting ./composer.json to its original content.


  [Composer\Downloader\TransportException]
  The "http://packagist.org/p/provider-2014%241cf88bd0ed4076dc091407477ba2a76483e8598ee5365673381262e6c1d40fcf.jso
  n" file could not be downloaded: failed to open stream: HTTP request failed!


require [--dev] [--prefer-source] [--prefer-dist] [--no-plugins] [--no-progress] [--no-update] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] [<packages>]...

I am running a windows 10 OS and am suspecting that my system cannot download from the command line. I would be very glad if someone can help me solve this problem because it is hindering my project. Thanks in advance.

13 Answers

You could also run this command on the CLI before installing any dependencies. It forces composer to use https to download all resources:

composer config -g repo.packagist composer https://packagist.org

I just updated my composer to the latest version and this problem is solved.

Try

composer self-update

To know the current version and update details:

composer diagnose

I tried the command below and it worked.

composer config -g repo.packagist composer https://packagist.org

This is just one of the options given above.

I found enabling OpenSSL extension in the php.ini-development/production file fixed the problem. Its located within your PHP install

just stop your antivirus software :)

for some reason antivirus software kaspersky doesn't like composer :(

I had the same error tried everything... nothing worked.

I remembered I had issues with composer in the past while my AV was on... turned it off and composer worked like a charm :)

  1. Update or Delete your 'http_proxy' variable.
  2. Delete composer
  3. Install Composer again
  4. Restart your machine.

Your are good to go.

try with composer diagnose and after that composer update -vvv

just put this in command

composer config -g repo.packagist composer https://packagist.org

I had the same error, but it was resolved in a different way for me. I used to give sudo to composer commands because folder /home/aspire/.composer is in sudo permission. I changed it to sudo chown $USER /home/aspire/.composer.

I changed the permissions as I mentioned and I ran the code

sudo composer require symfony/orm-pack

Throws error

[Composer\Downloader\TransportException]                                      
  The "https://repo.packagist.org/packages.json" file could not be downloaded:  

Then I tried

composer require symfony/orm-pack

It works

If anyone know the exact reason, please commententer image description here

if you are in china like me,try this:https://developer.aliyun.com/composer github connection not stable recently.I tryed https://pkg.phpcomposer.com/ first but don't work. I tryed composer diag and composer -vvv and wait.out put show cache file is :Writing C:/Users/Administrator.000/AppData/Local/Composer/repo.so i copy cache file from my colleague,and it works first,laravel run,but composer require show 404.then i found the solution above.try composer update -lock and change the repositories url to ali's.And solved.

This problem happened to me, and I solved it by turning off the firewall. This is one of the solutions.

If you have http_proxy environment variable, just delete it from either User variables or System variable and save yourself from all this trouble.

Related