Composer and Git on Windows


I’ve been having some problems downloading packages using Composer. It seems GitHub is having some hickups and it’s returning errors such as:

[Composer\Downloader\TransportException]                                     
  The "http://nodeload.github.com/symfony/Yaml/zipball/v2.1.3" file could not be downloaded (HTTP/1.1 404 Not Found)    

As a workaround you can use the

--prefer-source

flag to tell Composer to download the source code rather than using a bundled package. However, this means that you must have Git on your path, otherwise composer won’t be able to find it.

When I installed git, I chose the option to use the git shell, and as a result it didn’t put it on my path. I could put the cmd folder in the git installation location on the path, but instead of polluting my path, I decided to modify the composer.bat file to set the path to git.

@ECHO OFF
 
rem Include GIT on the path
SET PATH=%PATH%;C:\Program Files (x86)\Git\cmd
 
SET composerScript=composer.phar
php "%~dp0%composerScript%" %*

On Windows 7, if you used the composer installer, composer.bat should be in C:\ProgramData\Composer\bin. Make sure you change the path to git to reflect your environment.

  1. #1 by Rafff on December 27, 2012 - 9:32 am

    Thanks so muck for this trick, this bug was making me crazy

  2. #2 by Tunji on April 12, 2013 - 2:45 am

    Thanks for this – it’s saved me.

  3. #3 by nessrine on April 12, 2014 - 7:39 am

    I’ve been having some problems downloading packages using Composer. It seems GitHub is having some hickups and it’s returning errors such as:

    [Composer\Downloader\TransportException]
    The “http://nodeload.github.com/symfony/Icu/zip/fdba214b1e087c149843”

(will not be published)