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

-bash: laravel:命令未找到

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

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

但我不知道该怎么做。

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


当前回答

终端类型:

nano ~/.bash_profile 

然后粘贴:

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

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

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

其他回答

如果你是2021年来到这里,这也适用于我使用Ubuntu 16.04

nano ~/.bash_profile 
export PATH=$HOME/.config/composer/vendor/bin:$PATH
ctrl+x and save 
source ~/.bash_profile

将以下内容添加到.zshrc文件中

微,多达/。zshrc或nano~/.zshrc

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

在文件的末尾。

zsh不知道~,所以用$HOME代替。

来源 ~/.zshrc

完成了!试试命令laravel你就会明白了。

如果你使用的是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

Composer应该全局安装: 在你的终端上运行:

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

现在编写器命令可以工作了。

我设置了PATH,但它不起作用。我会找到其他解决方法。(OSX 10.10 & laravel 5.2) 1)找到可执行文件:

~/.composer/vendor/laravel/installer/laravel 

2)给予执行权限:

chmod +x ~/.composer/vendor/laravel/installer/laravel 

3)软链接到/usr/bin:

sudo ln -s /Users/zhao/.composer/vendor/laravel/installer/laravel /usr/bin/laravel