>  기사  >  php教程  >  composer安装,composer

composer安装,composer

WBOY
WBOY원래의
2016-06-13 08:45:56792검색

composer安装,composer

通过 Composer 镜像安装 composer

务必确保已经正确安装了PHP

局部安装

局部安装是将 composer 安装到当前目录下面(比如安装到项目根目录下),然后就可以通过 php composer.phar 来使用 composer 了。

Mac 或 Linux 系统:打开命令行窗口并执行如下命令:

<code class="language-bash hljs">curl <span class="hljs-operator">-sS http://install.phpcomposer.com/installer | php
</span></code>

Windows 系统(Mac 或 Linux 系统也可以使用):请执行如下命令:

<code class="language-bash hljs">php -r <span class="hljs-string">"readfile('http://install.phpcomposer.com/installer');" | php</span></code><br /><br />

全局安装

全局安装是将 composer 安装到系统环境变量 PATH 所包含的路径下面,然后就能够在命令行窗口中直接执行 composer 命令了。

Mac 或 Linux 系统:打开命令行窗口并执行如下命令:

<code class="language-bash hljs">curl <span class="hljs-operator">-sS http://install.phpcomposer.com/installer | sudo php -- --install-dir=/usr/<span class="hljs-built_in">local/bin --filename=composer
</span></span></code>

Windows 系统:请在命令行中执行如下命令:

<code class="language-bash hljs">mkdir C:\bin
<span class="hljs-built_in">cd C:\bin
php -r <span class="hljs-string">"readfile('http://install.phpcomposer.com/installer');" | php
<span class="hljs-built_in">echo @php <span class="hljs-string">"%~dp0composer.phar" %*>composer.bat
</span></span></span></span></code>

上述命令执行成功之后再将 C:\bin 路径加入 PATH 环境变量即可。最后重新打开一个命令行窗口试一试执行 composer --version 看看是否正确输出版本号,例如:。

<code class="hljs css"><span class="hljs-tag">Composer <span class="hljs-tag">version 1<span class="hljs-class">.0-dev (72<span class="hljs-tag">cd6afdfce16f36a9fd786bc1b2f32b851e764f) 2015<span class="hljs-tag">-12-28 17<span class="hljs-pseudo">:35<span class="hljs-pseudo">:19</span></span></span></span></span></span></span></code>
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.