Composer uses %APPDATA%\Composer directory by default for global packages.
So I need to add %APPDATA%\Composer\vendor\bin path to my user PATH environment variable.
Can I change installation directory to something like C:\php\composer? How can I do it?
Step 1: Navigate to the official composer website. Step 2: Then click on the Download button. Step 3: Then click on the Composer-Setup.exe & download the file. Step 4: Then click on “Install for all users”.
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

(source: w3guy.com)
Click the Environmental variables button.

(source: w3guy.com)
Under System variables, click New... button and add the environmental variable like so:

(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/
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.
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) .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With