laravel - 在本地主机上运行 php artisan serve 命令时出错
问题描述
我遇到了php artisan serve
命令问题。我正在处理一个 Laravel 项目,当我从浏览器访问该文件夹时,它工作正常,但是当我运行php artisan serve
命令时,它向我显示以下错误:
警告:需要(E:\xampp\htdocs\www\LFS\public../vendor/autoload.php):无法打开流:E:\xampp\htdocs\www\LFS\public\ 中没有这样的文件或目录第 24 行的 index.php
致命错误:require():在 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
命令上运行。
解决方案
在您的项目文件夹中,缺少供应商文件夹,因此您收到此错误:
警告:需要(E:\xampp\htdocs\www\LFS\public../vendor/autoload.php):无法打开流:没有这样的文件或目录
只需运行以下命令:
composer update --no-scripts
composer update
使用此命令,您将在项目中重新创建供应商文件夹
推荐阅读
- node.js - 使用 Cassandra DB 的 NodeJS 应用程序中的数据加密
- postgresql - 如何通过spring data jdbc将枚举java转换为枚举postgres
- impala - 我们可以使用 spring 存储库类连接到 impala 吗?
- r - 在 R 中是否可以使用数据库中存在的用户定义表类型 (UDT) 来执行带有基于此 UDT 的参数的存储过程?
- twilio - Twilio 可编程语音软电话?
- java - commitTransaction 失败:CloseSafeProducer,多线程的 Kafka 事务
- c++ - 点深度缓冲区未正确排序
- ios - React Native,展览屏幕方向
- mongodb - MongoDB Sink 连接器:Apache Kafka 中的消息被截断
- mysql - 使用 Express、Express-handlebards 无法发布错误