我已经安装Laravel使用作曲家没有问题,但当我试图在我的终端执行“Laravel”时,我有这个典型的错误:
-bash: laravel:命令未找到
如果我阅读官方网站的文档,我需要这样做:
确保将~/.composer/vendor/bin目录放在PATH中,这样当您在终端中运行laravel命令时,就可以找到laravel可执行文件。
但我不知道该怎么做。
你能帮我一下吗?谢谢! !
我已经安装Laravel使用作曲家没有问题,但当我试图在我的终端执行“Laravel”时,我有这个典型的错误:
-bash: laravel:命令未找到
如果我阅读官方网站的文档,我需要这样做:
确保将~/.composer/vendor/bin目录放在PATH中,这样当您在终端中运行laravel命令时,就可以找到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
其他回答
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
解决方案链接http://tutsnare.com/laravel-command-not-found-ubuntu-mac/
在终端
# download installer
composer global require "laravel/installer=~1.1"
#setting up path
export PATH="~/.composer/vendor/bin:$PATH"
# check laravel command
laravel
# download installer
composer global require "laravel/installer=~1.1"
nano ~/.bashrc
#add
alias laravel='~/.composer/vendor/bin/laravel'
source ~/.bashrc
laravel
# going to html dir to create project there
cd /var/www/html/
# install project in blog dir.
laravel new blog
将以下内容添加到.bashrc文件(不是.bash_profile)。
export PATH="~/.composer/vendor/bin:$PATH"
在文件的末尾,然后在终端运行source ~/.bashrc
验证如下:
回声路径美元
(重启终端,检查并确认路径是否存在)
执行laravel命令!
注意: 对于Ubuntu 16及以上版本,请使用以下方法:
export PATH="~/.config/composer/vendor/bin:$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
我创建一个新项目的快速方法
//在web根目录上安装composer -从https://getcomposer.org/download/运行代码
安装laravel:
php composer.phar require laravel/installer
然后创建项目,不向任何路径添加任何东西
vendor/laravel/installer/bin/laravel new [ProjectName]
//添加项目到git
cd ProjectName
git init
git remote add origin git@...[youGitPathToProject]
想知道这种方式是否有任何问题-请让我知道