Search code examples
phplaravelbashcomposer-phpcommand

Laravel PHP command not found


I installed Laravel using Composer without problems, but when I try to run laravel in the terminal, I get the following error:

-bash: laravel: command not found

The docs say that I need to do the following:

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.

How can I do that?


Solution

  • 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.