Is there any way to install Composer globally on Windows?
Sure. Just put composer.phar somewhere like C:\php\composer.phar
, then make a batch file somewhere within the PATH called composer.bat
which does the following:
@ECHO OFFphp "%~dp0composer.phar" %*
The "%*" repeats all of the arguments passed to the shell script.
Then you can run around doing composer update
all ya want!
Go to php.exe located folder.
C:\wamp\bin\php\php5.5.12\
open cmd there, and execute below command.
php -r "readfile('https://getcomposer.org/installer');" | php
composer.phar
will be downloaded in same folder.
Create folder named composer
in C://
drive (or anywhere you wish, for upcoming steps, remember the path).
move composer.phar
file to C://composer
folder.
Create composer.bat
file in same folder with contents below
@ECHO OFFphp "%~dp0composer.phar" %*
create file named composer
without any extensions.
running command type NUL > composer
in CMD will help to get it done quickly,
Open that file and place below contents inside it.
#!/bin/shdir=$(d=$(dirname "$0"); cd "$d" && pwd)# see if we are running in cygwin by checking for cygpath programif command -v 'cygpath' >/dev/null 2>&1; then # cygwin paths start with /cygdrive/ which will break windows PHP, # so we need to translate the dir path to windows format. However # we could be using cygwin PHP which does not require this, so we # test if the path to PHP starts with /cygdrive/ rather than /usr/bin. if [[ $(which php) == /cygdrive/* ]]; then dir=$(cygpath -m $dir); fifidir=$(echo $dir | sed 's/ /\ /g')php "${dir}/composer.phar" $*
Save.
Now set path
, So we can access composer from cmd.
Show Desktop.
Right Click My Computer shortcut in the desktop.
Click Properties.
You should see a section of control Panel - Control Panel\System andSecurity\System.
Click Advanced System Settings on the Left menu.
Click Environment Variables towards the bottom of the window.
Select PATH in the user variables list.
Append your PHP Path (C:\composer) to your PATH variable, separatedfrom the already existing string by a semi colon.
Click OK
Restart your machine.
Or, restart explorer
only using below command in CMD.
taskkill /f /IM explorer.exestart explorer.exeexit
Original Article with screenshots here : http://aslamise.blogspot.com/2015/07/installing-composer-manually-in-windows-7-using-cmd.html