Laravel PHP Command Not Found
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: command not found
If I read the documentation of the official site I need to do that:
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!!
Solution 1:
Ok, I did that and it works:
nano ~/.bash_profile
And paste
export PATH=~/.composer/vendor/bin:$PATH
do source ~/.bash_profile
and enjoy ;)
Important: If you want to know the difference between bash_profile and bashrc please check this link
Note: For Ubuntu 16.04 running laravel 5.1, the path is: ~/.config/composer/vendor/bin
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
.
Solution 2:
Add the following to .bashrc
file (not .bash_profile
).
export PATH="~/.composer/vendor/bin:$PATH"
at the end of the file and then in terminal run source ~/.bashrc
To verify that:
echo $PATH
(Restart the terminal, Check & Confirm the path is there)
Run the laravel command!
Note: For Ubuntu 16 and above use below:
export PATH="~/.config/composer/vendor/bin:$PATH"
Solution 3:
When using MacBook, refer to the snippets below;
For zsh:
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
For Bash:
echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc