我已经安装Laravel使用作曲家没有问题,但当我试图在我的终端执行“Laravel”时,我有这个典型的错误:
-bash: laravel:命令未找到
如果我阅读官方网站的文档,我需要这样做:
确保将~/.composer/vendor/bin目录放在PATH中,这样当您在终端中运行laravel命令时,就可以找到laravel可执行文件。
但我不知道该怎么做。
你能帮我一下吗?谢谢! !
我已经安装Laravel使用作曲家没有问题,但当我试图在我的终端执行“Laravel”时,我有这个典型的错误:
-bash: laravel:命令未找到
如果我阅读官方网站的文档,我需要这样做:
确保将~/.composer/vendor/bin目录放在PATH中,这样当您在终端中运行laravel命令时,就可以找到laravel可执行文件。
但我不知道该怎么做。
你能帮我一下吗?谢谢! !
当前回答
Composer应该全局安装: 在你的终端上运行:
mv composer.phar /usr/local/bin/composer
现在编写器命令可以工作了。
其他回答
如果你使用的是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 create-project --prefer-dist laravel/laravel youprojectname
迟到的回答…
电话1.10.1 2020-03-13 20:34:27 laravel版本—— Laravel安装程序3.0.1
把 导出路径= $路径:~ / config /作曲家/供应商/ bin:美元的道路 在你的~/。ZSHRC或~/.bashrc ~ /来源。ZSHRC或~/.bashrc 这是
好吧,我这么做了,效果很好:
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中的路径。
如果你是2021年来到这里,这也适用于我使用Ubuntu 16.04
nano ~/.bash_profile
export PATH=$HOME/.config/composer/vendor/bin:$PATH
ctrl+x and save
source ~/.bash_profile