Installing composer manually and setting composer path in windows 7
Published by Aslam
Go to php.exe located folder. if you are using WampServer, probably
"C:\wamp\bin\php\php5.5.12\"
press and hold CTRL + SHIFT together and right click inside folder, and select "open command window here ".
Copy and paste this code in CMD.
php -r "readfile('https://getcomposer.org/installer');" | php
If everything's fine, it will show message like,
"
#!/usr/bin/env php All settings correct for using Composer Downloading... Composer successfully installed to: C:\wamp\bin\php\php5.5.12\composer.phar Use it: php composer.phar"
you can see composer.phar file in same folder.
Go to C:/ drive and create a folder named composer
Move downloaded composer.phar to that folder.
Create composer.bat file in same folder and copy below contents to that file.
@ECHO OFF php "%~dp0composer.phar" %*
create
composer
file. without any extensions, you can do this by opening CMD in this folder and typing type NUL > composer
without Quotes.and drag that file to your text editor, preferably notepad++ . and paste below contents.
#!/bin/sh dir=$(d=$(dirname "$0"); cd "$d" && pwd) # see if we are running in cygwin by checking for cygpath program if 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); fi fi dir=$(echo $dir | sed 's/ /\ /g') php "${dir}/composer.phar" $*
save.
Now 3 files will be there inside composer folder.
Now, set PATH to composer so we can access composer by just typing composer in CMD.
- Show Desktop.
- Right Click My Computer shortcut in the desktop.
- Click Properties.
- You should see a section of control Panel - Control Panel\System and Security\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, separated from the already existing string by a semi colon.
- Click OK
Finally,
restart computer.
If you dont want to restart computer, there is an alternate way,
Open CMD and copy paste below lines.
taskkill /f /IM explorer.exe start explorer.exe exit
Open a new command prompt, and type composer
Now you should see composer is installed and working properly.
Feel free to be part of discussion.