在本地主机上运行php artisan serve命令时出错

时间:2019-07-19 06:56:57

标签: laravel artisan serve

我遇到php artisan serve命令的问题。我正在一个Laravel项目上工作,当我从浏览器访问该文件夹时,它工作正常,但是当我运行php artisan serve命令时,它显示了以下错误:

  

警告:   require(E:\ xampp \ htdocs \ www \ LFS \ public ../ vendor / autoload.php):失败   打开流:在中没有这样的文件或目录   E:\ xampp \ htdocs \ www \ LFS \ public \ index.php,第24行

     

严重错误:require():无法打开所需的'E:\ xampp \ htdocs \ www \ LFS \ public ../ vendor / autoload.php'   (include_path ='E:\ xampp \ php \ PEAR')在   E:\ xampp \ htdocs \ www \ LFS \ public \ index.php,第24行

我是Laravel的新手,请让我知道我要去哪里了。

我已经检查了下面 public / index.php 文件中的代码。我想一切都很好,我只是将相同的 index.php 文件复制并粘贴到我的根文件夹中。

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <taylor@laravel.com>
 */

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/

require __DIR__.'../vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

$app = require_once __DIR__.'../bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

我希望可以从浏览器直接访问该项目,并且还应该在php artisan serve命令上运行。

1 个答案:

答案 0 :(得分:0)

在您的项目文件夹中,缺少供应商文件夹,因此您收到此错误:

  

警告:   require(E:\ xampp \ htdocs \ www \ LFS \ public ../ vendor / autoload.php):失败   打开流:没有这样的文件或目录

只需运行以下命令:

composer update --no-scripts 
composer update

使用此命令,您将在项目中重新创建供应商文件夹