如何在 macOS 上安装 Composer?

问题描述 投票:0回答:4

我尝试在我的 macOS 版本上安装 Composer:

high sierra--> 10.13.4

但是使用命令后:

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

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

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

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

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

如何解决这个问题?

php macos shell composer-php
4个回答
69
投票

旧答案(Ruby Homebrew 安装程序现已弃用,并已在 猛击。):

首先在您的 MAC 上安装 Brew:

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

新答案:

首先在您的 MAC 上安装 Brew:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

然后安装PHP:

brew update
brew install php
brew install composer

要测试安装,请运行:

 $ composer -V

1
投票
  1. 在 Mac 终端中安装 Brew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

  1. 安装作曲家

brew install composer

  1. 检查作曲家

composer -V


0
投票

运行命令:

brew install composer

检查这里


-7
投票
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.
© www.soinside.com 2019 - 2024. All rights reserved.