我已经安装Laravel使用作曲家没有问题,但当我试图在我的终端执行“Laravel”时,我有这个典型的错误:

-bash: laravel:命令未找到

如果我阅读官方网站的文档,我需要这样做:

确保将~/.composer/vendor/bin目录放在PATH中,这样当您在终端中运行laravel命令时,就可以找到laravel可执行文件。

但我不知道该怎么做。

你能帮我一下吗?谢谢! !


当前回答

MAC用户:

1. 打开终端

cd ~

2. 仔细检查$PATH

echo $PATH

3.编辑文件

nano ~/.bash_profile

4. 粘贴

export PATH="~/.composer/vendor/bin:$PATH"

别忘了加引号。

5. control + X (y + enter保存文件并退出)

现在开始vagrant,打开你的文件夹试试:

laravel new yourprojectname

其他回答

终端类型:

nano ~/.bash_profile 

然后粘贴:

export PATH="/Users/yourusername/.composer/vendor/bin:$PATH"

然后保存(按ctrl+c,按Y,按enter)

现在,您可以在终端上使用“laravel”了

使用MacBook时,请参考下面的代码片段;

zsh:

echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >>  ~/.zshrc
source ~/.zshrc

Bash的:

echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

如果你已经全局安装了Composer,你可以使用下面的命令安装Laravel安装工具:

composer global require "laravel/installer=~1.1"

好吧,我这么做了,效果很好:

nano ~/.bash_profile 

粘贴

export PATH=~/.composer/vendor/bin:$PATH

做源~/。Bash_profile和enjoy;)

重要提示:如果你想知道bash_profile和bashrc的区别,请点击这个链接

注意:对于运行laravel 5.1的Ubuntu 16.04,路径为:~/.config/composer/vendor/bin

在其他平台上:要查看Composer全局目录的位置,请运行Composer global about。将/vendor/bin添加到“Changed current directory to…”之后列出的目录中,以获得应该添加到path中的路径。

如果你使用的是Ubuntu 16.04。

You need to find the composer config files in my case is : ~/.config/composer or in other cases ~/.composer/ you can see the dir after this command composer global require "laravel/installer" after Laravel Installed you can find your laravel in ~/.config/composer/vendor/laravel/installer/. and you will find the Laravel shortcut command in here : ~/.config/composer/vendor/bin/ set your .bashrc using nano ~/.bashrc and export your composer config file : export PATH="$PATH:$HOME/.config/composer/vendor/bin" or you can use allias. but above solution is recommended. alias laravel='~/.config/composer/vendor/laravel/installer/laravel' Now refresh your bashrc using source ~/.bashrc and then laravel is ready!!

以上步骤适用于我的Ubuntu 16.04