What you're doing when you use PATH="~/.config/composer/vendor/bin:$PATH"
from the command line, is temporarily adding that PATH while you are within a session in your terminal. Once you close the terminal, you end the session, the PATH you added is removed along with session, and the terminal forgets all about where Laravel is located.
Permanently add your PATH, using the .profile file
tl;dr
Add this line to your shell's profile file:
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
Each time you open your terminal, it processes a few files to gather information about the environment. In order to permanently let your terminal know about Laravel's location, you will need to add the composer directory to one of these processed files.
- Figure out which shell you're using: type
echo $0
in your terminal
- From the output of this command, determine which shell you're using, and which .profile file it uses:
- usr/sh: the file is
.profile
- bash: the file is
.bash_profile
- /usr/bin/zsh: the file is
.zprofile
- You might have to figure it out if you're using a different shell. But it's not hard cause most of the files out there follow the same sort of naming, and exist in your HOME directory
- Open your shell's .profile file. It should be located in your HOME directory.
- Add the following to that file, on it's own line, and then save it.
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
- this is processed every time you open a new terminal, that's how it will now know where to find Laravel
- you can also use composer to figure out what the path to composer's global config directory is by using this in your profile instead
export PATH="$(composer config -g home)/vendor/bin:$PATH"
- Restart your terminal and the PATH to Laravel will now be permanently set
Quickest way is to just type this command in your terminal
- type
echo "export PATH=$(composer config -g home)/vendor/bin:$PATH" >> ~/.profile
in your terminal, making sure to swap out .profile for your shell's profile file.
- The double ">>" appends the output of the echo command (which is just the text in the quoted portion of the command), to the profile file
- If you use single ">" it will overwrite the entire file with only the echoed PATH, so be careful. The path will still be set if you use single ">", it will just hose anything that existed inside that file.
- $(composer config -g home) is explained above
- Restart your terminal and the PATH to Laravel will now be permanently set