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.
Can you help me with that? Thanks!!
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.
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"
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
Solution on link http://tutsnare.com/laravel-command-not-found-ubuntu-mac/
In terminal
# 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
Type on terminal:
composer global require "laravel/installer"
When composer finish, type:
vi ~/.bashrc
Paste and save:
export PATH="~/.config/composer/vendor/bin:$PATH"
Type on terminal:
source ~/.bashrc
Open another terminal window and type: laravel
If you're using 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!!
above steps works with me in Ubuntu 16.04
For zsh and bash:
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
source ~/.zshrc
source ~/.bashrc
For bash only:
export PATH=~/.config/composer/vendor/bin:$PATH
source ~/.bashrc
For Developers use zsh Add the following to .zshrc file
vi ~/.zshrc or nano ~/.zshrc
export PATH="$HOME/.composer/vendor/bin:$PATH"
at the end of the file.
zsh doesn't know ~ so instead it by use $HOME.
source ~/.zshrc
Done! try command laravel you will see.
If on mac (and think *nix) just run this in your terminal.
export PATH="~/.composer/vendor/bin:$PATH"
For those using Linux with Zsh:
1 - Add this line to your .zshrc file
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
2 - Run
source ~/.zshrc
Linux path to composer folder is different from Mac
Use $HOME instead of ~ inside the path with Zsh
The .zshrc file is hidden in the Home folder
export PATH= exports the path in quotes so that the Laravel executable can be located by your system
The :$PATH is to avoid overriding what was already in the system path
If you are coming here 2021 this has worked for me also using Ubuntu 16.04
nano ~/.bash_profile
export PATH=$HOME/.config/composer/vendor/bin:$PATH
ctrl+x and save
source ~/.bash_profile
For MAC users:
1. Open terminal
cd ~
2. Double check the $PATH
echo $PATH
3. Edit file
nano ~/.bash_profile
4. PASTE
export PATH="~/.composer/vendor/bin:$PATH"
Don't forget to put quotation marks.
5. control + X (y + enter to save the file and exit)
Now start vagrant, go to your folder and try:
laravel new yourprojectname
I set the PATH,but it didn't work.I find other way to solve it. (OSX 10.10 & laravel 5.2)
1) find the executable file:
~/.composer/vendor/laravel/installer/laravel
2) give execute permissions:
chmod +x ~/.composer/vendor/laravel/installer/laravel
3) make a soft link to /usr/bin:
sudo ln -s /Users/zhao/.composer/vendor/laravel/installer/laravel /usr/bin/laravel
1) First, download the Laravel installer using Composer:
composer global require "laravel/installer"
2) Make sure to place the ~/.composer/vendor/bin directory in your PATH so the laravel executable can be located by your system.
set PATH=%PATH%;%USERPROFILE%\AppData\Roaming\Composer\vendor\bin
eg: “C:\Users\\AppData\Roaming\Composer\vendor\bin”
3) Once installed, the simple laravel new command will create a fresh Laravel installation in the directory you specify.
eG: laravel new blog
type on terminal:
nano ~/.bash_profile
then paste:
export PATH="/Users/yourusername/.composer/vendor/bin:$PATH"
then save (press ctrl+c, press Y, press enter)
now you are ready to use "laravel" on your terminal
If you have Composer installed globally, you can install the Laravel installer tool using command below:
composer global require "laravel/installer=~1.1"
Late answer...
Composer 1.10.1 2020-03-13 20:34:27
laravel --version
Laravel Installer 3.0.1
Put
export PATH=$PATH:~/.config/composer/vendor/bin:$PATH
in your ~/.zshrc or ~/.bashrc
source ~/.zshrc or ~/.bashrc
This works
Composer should be installed globally:
Run this in your terminal:
mv composer.phar /usr/local/bin/composer
Now composer commands will work.
My quick way of creating a new project
//install composer locally on web root - run the code from: https://getcomposer.org/download/
Then install laravel:
php composer.phar require laravel/installer
Then create the project without adding anything to any path
vendor/laravel/installer/bin/laravel new [ProjectName]
//add project to git
cd ProjectName
git init
git remote add origin git#...[youGitPathToProject]
Wondering if this way of doing it has any issues - please let me know
Just use it:
composer create-project --prefer-dist laravel/laravel youprojectname
Related
I am using MAMP on macOS 12 (Monterey), so I want to run through MAMP to use PHP. Therefor I added this alias:
nano ~/.bash_profile
alias phpmamp='/Applications/MAMP/bin/php/php5.4.10/bin/php'
Then I ran:
curl -sS https://getcomposer.org/installer | phpmamp
Which resulted in:
Composer (version 2.4.2) successfully installed to: /Users/johnmiles/composer.phar
Use it: php composer.phar
Then I made it available globally:
sudo mv composer.phar /usr/local/bin/composer
But when I run composer I get:
env: php: No such file or directory
So how do I tell composer to use phpmamp?
Within the Terminal, run vim ~/.bash_profile
Type i and then paste the following at the top of the file:
export PATH=/Applications/MAMP/bin/php/php8.0.8/bin:$PATH
Hit ESC, Type :wq, and hit Enter
In Terminal, run source ~/.bash_profile
In Terminal, type in which php again and look for the updated string. If everything was successful, It should output the new path to MAMP PHP install.
In case it doesn't output the correct path, try closing the terminal window (exit fully) and open again, it should apply the changes (Restart in short).
The Laravel installation guide says:
First, download the Laravel installer using Composer:
composer global require "laravel/installer"
Make sure to place the $HOME/.composer/vendor/bin directory (or the
equivalent directory for your OS) in your $PATH so the laravel
executable can be located by your system.
Why can't laravel just be installed to /usr/bin like a normal executable?
Is making a symlink instead of adding the path a good idea?
ln -s $HOME/.config/composer/vendor/bin /usr/bin/laravel
Why doesn't composer do this by default?
on MacOS 10.12 I have solve the issue.
after execute the command on terminal
composer global require "laravel/installer"
composer will install laravel/installer on your computer.
Find the location where is installed Laravel installer. Then add a line on ~/.bash_profile
export PATH=<laravel installer location>:$PATH
On my cace <laravel installer location> was /Users/shahriar/.composer/vendor/laravel/installer/bin/
So I have added the line on .bash_profile
export PATH=/Users/shahriar/.composer/vendor/laravel/installer/bin:$PATH
then type a command on terminal source ~/.bash_profile it will update your .bash_profile
and its worked. and now my Laravel installer installed globally.
I am a newbie in Laravel and want to set up my first Laravel project. I am following the Laravel documentation. So far, I installed Composer and downloaded the Laravel installer using Composer.Now, the documentation says:
Make sure to place the $HOME/.composer/vendor/bin directory (or the equivalent directory for your OS) in your $PATH so the laravel executable can be located by your system.
To set up $PATH variable I have added this line of code in ~/.bashrc file:
export PATH="$PATH:$HOME/.composer/vendor/bin"
But, when I type laravel the terminal says:
laravel: command not found
I searched similar question but couldn't find the right $PATH variable for my OS which is Linux Mint 18.Can you tell me the right $PATH variable or equivalent directory for my OS?Thank You.
After doing more searching, Finally I got the answer to my own question. I find it here:
composer path for Linux Mint 18 This line of code should be added at the bottom of ~/.bashrc fie:
export PATH="$PATH:$HOME/.config/composer/vendor/bin"
Make sur composer is configured
composer global require "laravel/installer"
Then, you have to install Laravel first, with this command
composer global require "laravel/installer"
A simple Google search will do. Check the link below:
https://forums.linuxmint.com/viewtopic.php?t=180380
After install laravel using ' composer global require "laravel/installer" '
use the code code below. Its worked for me.
export PATH="$PATH:$HOME/.config/composer/vendor/bin"
I have installed composer on Centos 7 virtualbox with PHP 5.6.27. I will show the commands that I have used and the issues that I am now having. I should first say that all of these commands have worked on previous installations.
Okay so for starters here is what I used to install composer.
curl -sS https://getcomposer.org/installer | php
Followed by
mv composer.phar /usr/local/bin/composer
Now I am trying to install laravel via the commands listed below.
composer global require "acacha/adminlte-laravel-installer=~3.0"
Up to this point all of the commands listed above have successfully worked.
Now here is the current problem. When I try to run the following command I get an error.
laravel new laravel-with-admin-lte
-bash: /root/.composer/vendor/bin/laravel: No such file or directory.
I have tried a whole set of remedies for this message but it cannot find the .composer directory. Can anyone tell me where the correct .composer directory is and how I can modify it so that it looks to the proper location to finalize this installation?
I appreciate any solutions that you can provide me. I have struggled with this for two days straight and have googled everything under the sun. Hopefully, someone on here has had a similar solution with a valid resolution.
Put an alias to the freshly installed Laravel installer in your user configuration .bashrc:
nano ~/.bashrc
And place this inside the file:
alias laravel='~/.config/composer/vendor/bin/laravel'
And run the following to make sure your bashrc profile is reloaded:
source ~/.bashrc
laravel new project
download as superuser
download installer
sudo composer global require "laravel/installer=~1.1"
setting up path
export PATH="~/.composer/vendor/bin:$PATH"
check laravel command
laravel
I had the same problem, so I changed the directory.
This is the directory where your bash was created: /root/.config/composer
enter image description here
but when excute the laravel command, the system search en the directory : bash: /root/.composer/vendor/bin/laravel:
enter image description here
So, just you need to change the address /root/.config/composer/vendor to /root/.composer/vendor.
PD. sorry I am learning english, so it is a little bad.
I have composer installed, but checking the Laravel docs, I'm struggling with:
"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."
I'm not sure what to do here, could someone explain it to me?
Go to terminal and paste the next line:
nano ~/.bash_profile
After that paste the next line in nano:
export PATH="$PATH:$HOME/.composer/vendor/bin"
Done. Restart your terminal and enjoy laravel.
The PATH environment variable tells your system where to look when you run a command. By default ~/.composer/vendor/bin will not be in your PATH. Therefore, if you just attempt to run the command laravel after installing it via composer, your terminal will give you an error saying the command is not found. But if you use the entire path to the command (~/.composer/vendor/bin/laravel), it will execute successfully.
When you run the command composer global require "laravel/installer=~1.1", composer puts the laravel installer into the directory ~/.composer/vendor/bin (in *nix, ~ represents your home directory). Adding ~/.composer/vendor/bin to your PATH allows you to just execute the command laravel instead of having to use the full path of ~/.composer/vendor/bin/laravel.
Helpful Stuff:
How to set/change your PATH environment variable in OSX
Installing composer packages globally