Change composer global path (Windows)

Go to folder

(C:\Users(your user)\AppData\Roaming\Composer )

Then create new folder (vendor)

and

in vendor create (bin) and copy (C:\composer\composer.phar) to (bin) .


I found an answer in the source code: https://github.com/composer/composer/blob/master/src/Composer/Factory.php#L45

So environment variable COMPOSER_HOME must be defined as C:\php\composer.


On Windows, when global install of a library / package is done, composer stores the package in a Composer directory inside windows **application data folders** which by default is C:\Users{user name}\AppData\Roaming`.

To change this folder to say C:\php\composer, create a COMPOSER_HOME environmental variable with the value set to C:\php\composer.

The steps below explain how environmental variables are added in Windows. * Press Windows Key + Pause Break then click Advanced system Settings

Windows system settings
(source: w3guy.com)

Click the Environmental variables button.

Environmental variable button
(source: w3guy.com)

Under System variables, click New... button and add the environmental variable like so:

Add environmental variables in Windows
(source: w3guy.com)

You might want to restart your PC for this to take effect.

Credit: http://w3guy.com/change-composer-global-package-install-folder-windows/