无法在OS X上安装composer

时间:2014-12-27 12:34:23

标签: php macos composer-php

我在终端上做了这个:

$ curl -sS https://getcomposer.org/installer | php
输出是:

All settings correct for using Composer
Downloading...

Composer successfully installed to: /Applications/XAMPP/xamppfiles/htdocs/composer.phar
Use it: php composer.phar
然后我进入了:

$ sudo mv composer.phar /usr/local/bin

没有问题(它应该工作,因为usr / local / bin在我的$ PATH中)。但是我现在该如何运行呢?当我在命令行输入composer或composer.phar时,我得到:

-bash: composer: command not found
-bash: composer.phar: command not found

4 个答案:

答案 0 :(得分:7)

.phar PH P Ar chive的缩写 - 它是php可执行文件可以读取的格式,而不是它自己的可执行文件对。要运行它,您应该使用:

$ php /usr/local/bin/composer.phar

为了让您的生活更轻松,您当然可以定义一个别名:

$ alias composer="php /usr/local/bin/composer.phar"

然后从你的shell中调用composer

答案 1 :(得分:1)

你有没有检查你现在的路径 ls -al /usr/local/bin 检查执行权。

确保你能做到: sudo chmod a+x /usr/local/bin/composer.phar

首先看起来应该是composer.phar,因为你在ur mv命令中没有精确的新名称,如: sudo mv composer.phar /usr/local/bin/composer

答案 2 :(得分:0)

你做过composer.phar可执行文件吗? 如果没有,只需做 sudo chmod a + x /usr/local/bin/composer.phar

答案 3 :(得分:0)

$ curl -sS https://getcomposer.org/installer |  php
$ sudo mv composer.phar /usr/local/bin/composer
mv: rename composer.phar to /usr/local/bin/composer.phar: No such file or directory

解决方案: 确保$PATH中存在composer.phar和目录local,bin composer(/ usr / local / bin / composer)      其他

$ cd usr
usr$m kdir local
usr/local$m kdir bin
usr/local/bin$ mkdir composer

现在我们比

还存在local / bin / composer
$sudo mv /path to composer.phar /usr/local/bin/composer 
Password:
toto:~ macbookpro$ your composer.phar now is move to directory usr/local/bin/composer