Home >php教程 >php手册 >composer安装,composer

composer安装,composer

WBOY
WBOYOriginal
2016-06-13 08:45:56824browse

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>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn