尝试安装 Composer 以设置 Laravel 框架

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17079822/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 02:30:18  来源:igfitidea点击:

Trying to install composer to get set up with Laravel framework

laravelcomposer-php

提问by user1072337

I am trying to install composer on my Mac so that I can use the Laravel framework. I successfully downloaded composer through the terminal, and then I moved composer.phar to to usr/local/bin using the command: sudo mv composer.phar /usr/local/bin.

我正在尝试在我的 Mac 上安装 composer 以便我可以使用 Laravel 框架。我顺利地通过终端下载的作曲家,然后我搬到composer.phar向USR /本地/使用命令斌: sudo mv composer.phar /usr/local/bin

I then changed directories to my root directory where I have the laravel-master files. After changing to this directory in the terminal, and then using the command: composer install

然后我将目录更改为我的根目录,其中包含 laravel-master 文件。在终端中切换到这个目录后,然后使用命令:composer install

I receive the error: -bash: composer: command not found

我收到错误: -bash: composer: command not found

I have tried other variations (such as php composer.phar install, etc..), however, I keep receiving the same error.

我尝试了其他变体(例如php composer.phar install,等),但是,我一直收到相同的错误。

Any help would be much appreciated. Thank you!

任何帮助将非常感激。谢谢!

回答by peterm

Make sure that /usr/local/binis in your $PATH

确保它/usr/local/bin在你的$PATH

$ echo $PATH

Then execute

然后执行

$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer
                                       ^^^^^^^^ you didn't rename it 

For reference see

参考见

回答by Wilson Sanchez

I'm running Mavericks and had same problem. I changed /usr/local/bin/composerto /usr/bin/composerand it worked for me.

我正在运行小牛队并且遇到了同样的问题。我改变/usr/local/bin/composer/usr/bin/composer,它对我有用。

回答by Sabba Keynejad

for mac os x Mavericksand YosemiteEl capitan

适用于 mac os x MavericksYosemite El capan

Change

改变

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

To

sudo mv composer.phar /usr/bin/composer

Now if you just write composerin terminal, it will show you all available commands

现在,如果您只是composer在终端中编写,它会显示所有可用的命令

Then "if running MAMP" navagate you htdocs folder and run

然后“如果正在运行 MAMP”导航您的 htdocs 文件夹并运行

composer create-project laravel/laravel laratest

composer create-project laravel/laravel laratest

Hope that helps

希望有帮助

回答by Shaolin Fantastic

A quick copy-paste version including sudo:

包含 sudo 的快速复制粘贴版本:

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

回答by zwitterion

Now in 2017 I am using MacOS SIERRA 10.12.6 and sudo mv composer.phar /usr/bin/composerdoesn't work. It works for me sudo mv composer.phar /usr/local/bin/composer. Now I can run composer instead of php composer.pha

现在在 2017 年,我使用的是 MacOS SIERRA 10.12.6 并且sudo mv composer.phar /usr/bin/composer不起作用。它对我有用sudo mv composer.phar /usr/local/bin/composer。现在我可以运行 composer 而不是 php composer.pha