转到 php.exe 所在的文件夹。
C:\wamp\bin\php\php5.5.12\
在那里打开cmd,然后执行下面的命令。
php -r "readfile('https://getcomposer.org/installer');" | php
composer.phar 将下载到同一文件夹中。
在C:// 驱动器中创建名为composer 的文件夹(或任何您希望的位置,对于接下来的步骤,请记住路径)。
将composer.phar 文件移动到C://composer 文件夹。
在同一文件夹中创建composer.bat文件,内容如下
@ECHO OFF
php "%~dp0composer.phar" %*
创建名为 composer 的文件,不带任何扩展名。
在 CMD 中运行命令 type NUL > composer 将有助于快速完成它,
打开该文件并将下面的内容放入其中。
#!/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" $*
保存。
现在设置path,这样我们就可以从cmd访问composer了。
重启你的机器。
或者,仅在 CMD 中使用以下命令重新启动 explorer。
taskkill /f /IM explorer.exe
start explorer.exe
exit
这里有截图的原创文章:http://aslamise.blogspot.com/2015/07/installing-composer-manually-in-windows-7-using-cmd.html