简体   繁体   English

laravel:在 ubuntu 16.04 中找不到命令如何修复..?

[英]laravel: command not found in ubuntu 16.04 how to fix..?

I have installed composer, php and others for Laravel and after installing laravel it says laravel command not found.我已经为 Laravel 安装了 Composer、php 和其他软件,在安装 Laravel 后,它说没有找到 Laravel 命令。 I have tried to add this path but still not working.我尝试添加此路径,但仍然无法正常工作。

It says laravel: command not found .它说laravel: command not found

Here is where composer is installed :这是 Composer 的安装位置:

$ which composer
/usr/bin/composer

(终端截图)

What should I add to the PATH or how to solve the laravel command not found here?我应该在 PATH 中添加什么或如何解决此处未找到的 laravel 命令?

  If i run :
  composer create-project --prefer-dist laravel/laravel new-site-name

then i get然后我得到

在此处输入图片说明

try this one试试这个

First, install the Laravel installer package globally to make the laravel command available:首先,全局安装 Laravel 安装包,使laravel命令可用:

$ composer global require "laravel/installer"

Next, make sure global composer packages are in your for PATH so the command will be found.接下来,确保全局 composer 包在您的 for PATH以便找到该命令。 You can make the modification to your bashrc file like this:您可以像这样对 bashrc 文件进行修改:

$ echo 'export PATH="$HOME/.composer/vendor/bin:$PATH"' >> ~/.bashrc

Then reload .bashrc to apply the changes, using this command:然后使用以下命令重新加载 .bashrc 以应用更改:

$ source ~/.bashrc

Now try using the command again to create a new project:现在尝试再次使用该命令创建一个新项目:

$ laravel new new-site-name

If for some reason none of this works, you can still create a new Laravel project with composer (without using the Laravel installer package):如果由于某种原因这些都不起作用,您仍然可以使用 composer 创建一个新的 Laravel 项目(不使用 Laravel 安装程序包):

$ composer create-project --prefer-dist laravel/laravel new-site-name

In my development environment Ubuntu 20.04, I wrote:在我的开发环境 Ubuntu 20.04 中,我写道:

$ echo 'export PATH=$PATH:"$HOME/.config/composer/vendor/bin"' >> ~/.bashrc && source ~/.bashrc

Everything works fine!一切正常!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM