找不到 laravel 命令设置路径不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45567481/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 16:28:16  来源:igfitidea点击:

laravel command not found setting path does not work

laravel

提问by Nigel Smith

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

我已经在我的 Ubuntu 17.04 中使用以下过程通过 Composer 安装了 laravel,在最新的 Oracle Virtualbox 上运行:

Steps:

脚步:

1) composer global require "laravel/installer"

1) composer global require "laravel/installer"

2) nano .bashrc

2) nano .bashrc

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

3)我添加了导出 PATH="$PATH:$HOME/.composer/vendor/bin"

4) saved changes.

4) 保存更改。

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

我什至将此行添加到 .profile 注销然后重新登录,但我仍然找不到 laravel 命令。

What am I doing wrong?

我究竟做错了什么?

回答by Yuyang He

For MAC users:

MAC用户:

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

如果您是终端新手,请尝试关注此youtube视频。

回答by Oluwatobi Samuel Omisakin

You can save yourself the headache: install from composer:

您可以省去头疼的麻烦:从作曲家安装:

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

blogis your project's name

blog是你的项目名称

回答by Shashi Asanka Nawarathna

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

我的 Linux Mint 也有同样的问题。检查 Composer 文件夹路径,如果是这样,~/.config/composer那么您需要更改$PATH如下所示的变量。这应该可以解决问题:

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

回答by dilantha111

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

有时 Laravel 不在这条道路上。而是尝试 ~/.config/composer/vender/bin/。但请确保该路径中存在 laravel。

回答by Lerie Taylor

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:

这很可能是因为您没有正确设置目录。我以 root 身份安装了 laravel,所以我的目录是“/root/.composer/vendor/bin”。导航到您的主目录并执行以下操作:

  1. vi .profile
  2. add /root/.composer/vendor/binto the $PATH variable
  3. save file (:wq)
  4. source profile by typing: source .profile
  1. vi .profile
  2. /root/.composer/vendor/bin添加到 $PATH 变量
  3. 保存文件 (:wq)
  4. 输入源配置文件:source .profile

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

-- 记住,永远不要在生产服务器上通过 root 安装 --