今天开始学习laravel,laravel用composer 安装,在终端输入laravel new blog(project name)得时候,出现了以下问题laravel: command not found</span>
查看技术文档这么Make sure to place the ~/.composer/vendor/bin
directory in your PATH so the laravel
executable can be located by your system. 应当是要让~/.composer/vendor/bin/laravel在mac的环境变量里面。在网上查看资料发现了有以下解决方案:
export PATH="~/.composer/vendor/bin:$PATH"
尽管可行,但是当终端关闭之后,就不行了。也就是每次创建项目的时候都必须要输入一次。那种只是临时的解决方案。
还有就是
nano ~/.bashrc
输入:
alias laravel='~/.composer/vendor/bin/laravel'
保存然后在终端输入:
source ~/.bashrc
关闭终端输入laravel new blog
可行。