一、直接去網吧下載windows安裝EXE程序,傻瓜式安裝,so easy。php
二、經過命令行安裝,能夠直接在php目錄跑起來linux
php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php php -r "if (hash('SHA384', file_get_contents('composer-setup.php')) === 'fd26ce67e3b237fffd5e5544b45b0d92c41a4afe3e3f778e942e43ce6be197b9cdc7c251dcde6e2a52297ea269370680') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); }" php composer-setup.php php -r "unlink('composer-setup.php');"
第三步是安裝的步驟,能夠附加--version等。好比後面加--version=1.3.1就能夠直接安裝對應版本,不然將直接安裝最新版本的composer.官網有介紹。git
三、新建composer.bat文件,寫入內容:shell
@ECHO OFF php "%~dp0composer.phar" %*
配環境變量什麼的就不說了,相信你PHP的都配置過了。windows
這樣,在windows的命令行就能夠運行composer命令了。bash
四、可是,若是經過git bash,仍然不行。由於他是經過linux-shell運行。這樣解決。composer
目錄下新建composer文件,內容:ui
#!/usr/bin/env sh # php /path/to/composer.phar $* php `dirname $0`/composer.phar $*
#!/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" $*