找不到 Laravel PHP 命令
我已经使用 composer 安装了 Laravel 没有问题,但是当我尝试在终端中执行laravel"时,我遇到了这个典型的错误:
I have installed Laravel using composer without problems, but when I try to execute "laravel" in my terminal I have this typical error:
-bash: laravel: 命令未找到
-bash: laravel: command not found
如果我阅读了官方网站的文档,我需要这样做:
If I read the documentation of the official site I need to do that:
确保将 ~/.composer/vendor/bin 目录放在 PATH 中,以便在终端中运行 laravel 命令时找到 laravel 可执行文件.
Make sure to place the ~/.composer/vendor/bin directory in your PATH so the laravel executable is found when you run the laravel command in your terminal.
但我不知道该怎么做(我是终端控制台命令的新手).
But I don't know how to do (I'm new on terminal console commands).
你能帮我解决这个问题吗?谢谢!!
Can you help me with that? Thanks!!
好的,我这样做了,并且有效:
Ok, I did that and it works:
nano ~/.bash_profile
粘贴
export PATH=~/.composer/vendor/bin:$PATH
做 source ~/.bash_profile
并享受 ;)
重要:如果您想知道bash_profile 和bashrc 之间的区别,请查看此链接
Important: If you want to know the difference between bash_profile and bashrc please check this link
注意:对于运行 laravel 5.1 的 Ubuntu 16.04,路径为:~/.config/composer/vendor/bin
Note: For Ubuntu 16.04 running laravel 5.1, the path is: ~/.config/composer/vendor/bin
在其他平台上:要检查 Composer 全局目录的位置,请运行 composer global about
.将 /vendor/bin
添加到将当前目录更改为..."之后列出的目录,以获取应添加到 PATH
的路径.
On other platforms: To check where your Composer global directory is, run composer global about
. Add /vendor/bin
to the directory that gets listed after "Changed current directory to ..." to get the path you should add to your PATH
.