laravel 如何在 Mac 上安装 Composer?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21952723/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install Composer on a Mac?
提问by Don Kooijman
I'm trying to get the Laravel PHP framework installed and for that I need to install Composer. However I'm getting stuck there. I installed it before for Symfony but I couldn't get it to work so I think I deleted it.
我正在尝试安装 Laravel PHP 框架,为此我需要安装 Composer。但是我被困在那里。我之前为 Symfony 安装了它,但我无法让它工作,所以我想我删除了它。
When I open the terminal on Mac and enter one of the commands for installing composer like:
当我在 Mac 上打开终端并输入用于安装 Composer 的命令之一,例如:
curl -sS https://getcomposer.org/installer | php
I get:
我得到:
-bash: php: command not found
curl: (23) Failed writing body (0 != 1635)
Why is this?
为什么是这样?
采纳答案by Don Kooijman
I deleted some files that I should not have deleted. Did a repair install of OS X and now it works.
我删除了一些我不应该删除的文件。对 OS X 进行了修复安装,现在可以使用了。
回答by luhuiya
download file from https://getcomposer.org/installer
execute the file
执行文件
sudo php installer
- and move the file
- 并移动文件
mv composer.phar /usr/local/bin/composer
回答by Miroslav Trninic
Here it is:
这里是:
curl -s https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
回答by Mint
You can install it via Brew.
您可以通过 Brew 安装它。
First, install Brew;
首先,安装Brew;
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Then you can use Brew to install Composer;
然后就可以使用Brew来安装Composer了;
brew install composer
That's it, it's now installed. You can verify this by running composer --version
就是这样,现在已经安装好了。您可以通过运行来验证这一点composer --version
回答by Petr Je?ábek
try
尝试
~ which php
/usr/bin/php
curl -sS https://getcomposer.org/installer | /usr/bin/php
回答by Anjani Barnwal
just open your terminal and follow this steps, here odbase is username of my mac.
只需打开您的终端并按照以下步骤操作,这里的 odbase 是我的 mac 的用户名。
cd /Users/odbase/Downloads
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
php composer.phar
mv composer.phar /usr/local/bin/composer
(if this produce error please run with prefix sudo. {sudo mv composer.phar /usr/local/bin/composer})
(如果这产生错误,请使用前缀 sudo 运行。{sudo mv composer.phar /usr/local/bin/composer})
installed for check
安装检查
cd /usr/local/bin
ls
回答by Siyaram Malav
First install brew if not installed in Mac:
如果 Mac 中未安装,请先安装 brew:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Update brew and install php and composer.
更新 brew 并安装 php 和 composer。
$ brew update
$ brew install php
$ brew install composer
Verify by checking version:
通过检查版本来验证:
$ composer -V
I hope it helps.
我希望它有帮助。