19

I am have installed laravel via composer using the following procedure in my Ubuntu 17.04 running on the latest Oracle Virtualbox:

Steps:

1) composer global require "laravel/installer"

2) nano .bashrc

3) I added export PATH="$PATH:$HOME/.composer/vendor/bin"

4) saved changes.

I even added this line to .profile logged out then back in again but I am still getting laravel command not found.

What am I doing wrong?

4
  • do you found laravel binary on ~/.composer/vendor/bin? maybe you set wrong path Commented Aug 8, 2017 at 12:05
  • I think you might get this error because you are logged in as root Commented Aug 8, 2017 at 12:15
  • Did you reset apache? Commented Aug 8, 2017 at 12:39
  • 1) The first suggestion isn't clear. 2) I logged in as a standard user 3) I rebooted the host PC but still the same error. Commented Aug 8, 2017 at 12:47

8 Answers 8

15

For MAC users:

In terminal, type follow this:

 1. nano ~/.bash_profile
 2. export PATH="~/.composer/vendor/bin:$PATH"

If you are new in terminal, please try follow this youtube video.

Sign up to request clarification or add additional context in comments.

2 Comments

@sadek my pleasure :)
I don't get it. Why was this upvoted and even allowed to remain as an answer when the question clearly specified Ubuntu 17.04 ?
11

I had the same problem with my Linux Mint. Check the composer folder path if this in ~/.config/composer then you need to change the $PATH variable looks like below. This should solve the problem:

  1. nano .bashrc [ or nano .bash_profile ]
  2. export PATH=~/.config/composer/vendor/bin:$PATH [ Add this line and save it ]
  3. source .bashrc

Comments

10

You can save yourself the headache: install from composer:

composer create-project --prefer-dist laravel/laravel blog

blog is your project's name

5 Comments

I followed these instructions to the letter but still no joy laravel.com/docs/4.2/quick.
Oh you use laravel 4.2? what error did you see running composer create-project laravel/laravel your-project-name 4.2.*?
I saw the error I made, so I followed the instructions given in laravel.com/docs/5.4, but I am still getting a laravel command not found. Very frustrating!
I mean don't use laravel command. use composer to install laravel package. can you add (the full error you get to your question) after running the command i gave in my answer?
This one should be accepted .... don't know why programming has to be so hard ..
2

You need to edit bash_profile

nano ~/.bash_profile 

Copy/paste

export PATH=~/.composer/vendor/bin:$PATH

Then run

source ~/.bash_profile

Now you can use laravel command in your Terminal

Comments

2

You need to edit your .bashrc
nano ~/.bashrc

add this line
export PATH=$HOME/.config/composer/vendor/bin:$PATH

save and exit then close your terminal and reopen it run:
laravel

1 Comment

Thanks for this one, everybody say ~/.composer... then I didn't checked mine was ~/.config/composer...
1

Sometimes Laravel is not in that path. Instead try ~/.config/composer/vender/bin/. But make sure that laravel is exist in that path.

Comments

0

This is most likely because you haven't set the directory properly. I installed laravel as root so my directory was "/root/.composer/vendor/bin". Navigate to your home directory and do the following:

  1. vi .profile
  2. add /root/.composer/vendor/bin to the $PATH variable
  3. save file (:wq)
  4. source profile by typing: source .profile

-- remember, never install via root on a production server --

2 Comments

Don't do everything as root, and don't encourage that. Bad behavior because it breaks the user permission model.
I've modified my post to let people know not to do it as root but nowhere in my answer did I tell anyone to "do everything as root" or encourage it, but thanks for your concern.
0

If you receive this error, then there is issue with the path.You have to edit the .zshrc file and add this line

To edit the file run following command from terminal

nano ~/.zshrc

then enter this line inside that file

export PATH="$HOME/.composer/vendor/bin:$PATH"

enter image description here

To save press Control + X buttons.

Then press Y to save and Hit enter.

sometimes if you have duplicate paths it may bring errors

Big thanks to NILESH SHIRAGAVE https://snilesh.com/blog/solved-zsh-command-not-found-laravel/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.