如何在macOS上安装Composer?

时间:2018-08-02 15:08:39

标签: php macos shell composer-php

我试图在我的macOS版本high sierra--> 10.13.4

上安装Composer。

但使用命令后:

sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" 

它创建了一些文件和目录,但没有下载作曲家。 我的终端显示以下错误:

  

未启用日志处理-使用stderr日志记录

     

创建的目录:/ var / db / net-snmp

     

创建的目录:/ var / db / net-snmp / mib_indexes`

如何解决此问题?

2 个答案:

答案 0 :(得分:11)

首先在您的MAC上安装Brew:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

然后安装PHP:

brew update
brew tap homebrew/dupes
brew tap homebrew/php
brew install php
brew install composer

要测试安装,请运行:

 $ composer -V

答案 1 :(得分:0)

Install download the composer using the following curl  command in the 
terminal:

curl -sS https://getcomposer.org/installer | php

After the command, you will have composer.phar file in the current 
directory and the composer command is available as:

php composer.phar [composer commnad]

In order to make composer available globally, you have to move the 
recently downloaded composer.phar to local user’s bin folder as follow:

go to /usr/local/bin folder . You can click  Shift + Command + G to open 
the dialog to go to folder.

move the recently downloaded composer.phar in the usr/local/bin folder
create a alias using command  alias composer="php 
 /usr/local/bin/composer.phar"


Now, you can access the composer from the terminal simply using the 
composer  command. Thats it.