Repository navigation
Manual installation
The goal is to download Composer to a single directory and set things up so that it can be run from any location by typing: composer into a command window. This is what the Composer-Setup installer does automatically, but you can achieve the same in a few simple steps.
Composer is a PHP script that runs from the command line, through the PHP CLI (Command Line Interpreter). You can run this by typing path\to\my\php.exe -v, which will display the version of PHP that you are using, but it is much easier to type php -v. If this works for you then you are done, otherwise you must add the directory containing php.exe to your path.
As an alternative to the standard command window, Console is an open-source enhancement that lets you open multiple console windows in tabs and allows you to configure them to start in a directory that you choose. This means that you can have a Windows command prompt, a Git Bash and/or Cygwin console in separate tabs.
Decide where you want to install Composer to. This could be in your root at C:\composer or maybe in your home directory C:\Users\Me or C:\Users\Me\composer. You could even make it more Unix-y and create a C:\Users\Me\bin directory.
Once you have created the directory, cd (change directory) to it in your command window and type:
php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"which will download Composer into your directory. There are other ways of doing this. If you have curl installed you can type:
curl -s https://getcomposer.org/installer | php
Or if you have git installed you can use the above command in Git Bash. Note that if you see any Message Box errors running git bash, click past these and check that Composer has downloaded - these errors can sometimes be caused by an extension being listed in your php.ini after other extensions that require it.
If the installation has failed, then read the errors that are displayed, correct them in your php.ini and try again. Otherwise type php composer.phar and you should see the Composer help displayed.
Your computer does not know how to run the composer.phar script, but it does know how to run a batch file from a Windows command console, or a shell script from Cygwin or Git Bash. Adding these shims is how your simple command composer get translated into running this file. We will create these now.
Create a file called composer.bat in your directory and add the following to it:
@ECHO OFF
SET composerScript=composer.phar
php "%~dp0%composerScript%" %*
Create a file called composer in your directory (note there is no file extension) and add the following to it:
#!/bin/sh
# This file must be saved with Unix line endings, or cygwin will choke
DIR=`dirname "0ドル"`;
DIRECTORY=$(cd "${DIR}" && pwd)
if command -v 'cygpath' >/dev/null 2>&1; then
DIRECTORY=`cygpath -m $DIRECTORY`;
fi
PHAR="$(echo $DIRECTORY | sed 's/ /\ /g')/composer.phar"
php "${PHAR}" $*
Make sure you save this with Unix line-endings.
Finally you must add your directory to your path. Then open a new command window (so it pulls in your new settings) type composer and you should see the Composer help displayed. Full documentation can be found at http://getcomposer.org and a repository of packages can be browsed at Packagist.
There are plenty of online tutorials about changing your Path environmental variable, so we will not cover it here. It is worth mentioning though that your changes will not propogate through to running programs, so you will have to open them again. Failing this it may be necessary to either log-off, switch user or restart your computer.