I'm a newbie when it comes to Linux administration using bash... I was following a tutorial on how to install laravel 5.2 from here ... installed it successfully...
firstly I installed composer and ran the following command
composer global require "laravel/installer"
after this put this in my path too in ~/.zshrc
like this
export PATH="~/.composer/vendor/bin:$PATH"
When I run the laravel
command from the terminal I get the following error
➜ ~ laravel
zsh: command not found: laravel
If I echo $PATH
it shows it have added up in the path
Note: I have installed oh my zsh
on my terminal...
What do I have to do to get it working please help
I think ZSH won't expand the ~
on PATH
. Try this instead:
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
尝试这样做:
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
As a follow up to Chris' answer,
The command export PATH="$HOME/.composer/vendor/bin:$PATH"
will work , but only for your current terminal session .
If you would like the path to always be available when zsh launches, add PATH="$HOME/.composer/vendor/bin:$PATH"
to the bottom of your ~/.zshrc
file. Run the zsh
command or restart your terminal and laravel
will be available in every session you start.
I got the same problem on macOS Sierra. Edit your .zshrc file with
PATH=~/.composer/vendor/bin:$PATH
That worked for me.
On Ubuntu 20.04 with zsh (Oh My ZSH!) and macos.
add Laravel cli with composer: composer global require laravel/installer
edit ~/.zshrc
add
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
run:
source ~/.zshrc
就我而言,我在结束文件 '.zshrc' 上添加了以下行:
export PATH="$HOME/.composer/vendor/bin:$PATH"
My solution was:
echo "PATH=\"$HOME/.config/composer/vendor/bin:$PATH\"" >> ~/.zshrc
source ~/.zshrc
laravel
More info here 👌
cd 进入项目目录并运行composer create-project --prefer-dist laravel/laravel blog
When you run command laravel
in your terminal, you call the laravel file inside composer/vendor/bin directory.
If none of the above works, then find where your vendor dir is by running:
composer global about
you will see something like: "Changed current directory to /home/username/.config/composer".
That means that your vendor dir is located in that path. Then add an alias in .zshrc file:
alias laravel="$HOME/.config/composer/vendor/bin/laravel"
.
Now you are pointing to the 'laravel' file in your filesys using the same command as you would normally.
or you can add composer to your path: export PATH="$HOME/.config/composer/vendor/bin:$PATH"
, which is the recomended way.
export PATH="$HOME/.config/composer/vendor/bin:$PATH"
or better still edit the .zshrc file as below
echo "PATH=\"$HOME/.config/composer/vendor/bin:$PATH\"" >> ~/.zshrc source ~/.zshrc
Try to do this:
macOS:
$HOME/.composer/vendor/bin
Windows:
%USERPROFILE%\AppData\Roaming\Composer\vendor\bin
GNU / Linux Distributions:
$HOME/.config/composer/vendor/bin or $HOME/.composer/vendor/bin
I too was getting the same error while creating a new Laravel project using composer but anything mentioned about the path didn't solved it and a simple trick help to resolve this issue.
Try to run this command on the terminal of your project folder :
composer global require laravel/installer
Article from laracasts helped me: https://laracasts.com/discuss/channels/laravel/laravel-command-not-found-by-zsh-on-macos
Put this to .zshrc file:
export PATH="$HOME/.composer/vendor/bin:$PATH"
And make sure you run:
source ~/.zshrc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.