简体   繁体   English

在 Laravel 5 中打开 autoload.php 失败

[英]Failed Opening autoload.php in Laravel 5

I have recently installed Laravel via Composer but I keep get the following error:我最近通过 Composer 安装了 Laravel,但我一直收到以下错误:

Warning: require(/home/leovoon/public_html/laravel-eee/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /home/leovoon/public_html/laravel-eee/bootstrap/autoload.php on line 17警告:需要(/home/leovoon/public_html/laravel-eee/bootstrap/../vendor/autoload.php):无法打开流:/home/leovoon/public_html/laravel-eee/bootstrap 中没有这样的文件或目录/autoload.php 第 17 行

Fatal error: require(): Failed opening required '/home/leovoon/public_html/laravel-eee/bootstrap/../vendor/autoload.php' (include_path='.:/opt/cpanel/ea-php71/root/usr/share/pear') in /home/leovoon/public_html/laravel-eee/bootstrap/autoload.php on line 17致命错误:require(): 需要打开失败 '/home/leovoon/public_html/laravel-eee/bootstrap/../vendor/autoload.php' (include_path='.:/opt/cpanel/ea-php71/root/ usr/share/pear') 在 /home/leovoon/public_html/laravel-eee/bootstrap/autoload.php 第 17 行

Am I missing something?我错过了什么吗? Because I followed it step by step.因为我是一步一步来的。

在此处输入图片说明

You got an error because you have missing vendor folder in your project, You need /vendor because all your packages are there, including all the classes Laravel uses.你得到一个错误,因为你的项目中缺少vendor 文件夹,你需要/vendor因为你的所有包都在那里,包括 Laravel 使用的所有类。 The vendor directory contains your Composer dependencies. vendor 目录包含您的 Composer 依赖项。

Your problem can be resolved after following this step.执行此步骤后即可解决您的问题。 you can try it:你可以试试看:

composer update --no-scripts 
composer update

With this command, you will re-create the vendor folder in your project and after that your project will start working normally.使用此命令,您将在项目中重新创建vendor 文件夹,然后您的项目将开始正常工作。

While Going Live This is my Project Structure上线时这是我的项目结构

NOTE:WHILE DOING THIS YOU MAY ENCOUNTER SOME STYLE AND JAVASCRIPT REFERENCE ERROR IF YOU ARE USNIG ASSET FUNCTION NO NEED TO WORRY注意:如果您是 USNIG ASSET FUNCTION此操作时您可能会遇到一些样式和 JAVASCRIPT 引用错误,无需担心

<link href="{{ asset('css/app.css') }}" rel="stylesheet">

BUT IF NOT IF WILL OCCUR 404 IN SOME CASES但如果不是,在某些情况下会发生 404

this is Just For Example这只是举例

Step 1 : create a folder named as `ProjectFiles` in root of your application

在此处输入图片说明

Step 2: copy all the contents except and folder except `public` folder and paste inside `ProjectFiles` folder

在此处输入图片说明

Step3: now cut and paste all the contents inside the public folder in root of your application root

在此处输入图片说明

step4: open your index.php file and make the following changes步骤 4:打开你的index.php文件并进行以下更改

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

to

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

AND

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

to

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

and then upload your project to live cpanel server然后将您的项目上传到实时 cpanel 服务器

here is my cpanel server directory structure这是我的 cpanel 服务器目录结构

hope it helps if the answer is not clear please comment below if the error continues如果答案不清楚,希望对您有所帮助,如果错误仍然存​​在,请在下方评论

在此处输入图片说明

Run composer with --no-scripts使用 --no-scripts 运行 composer

composer update --no-scripts  

This shall fix the issue.这将解决问题。

Run the command to install all the Laravel dependencies.运行命令安装所有 Laravel 依赖项。

php artisan composer:install

If the error still persists, run the command to include all the classes it requires.如果错误仍然存​​在,请运行该命令以包含它需要的所有类。

composer dump-autoload

You must provide Read and write permissions to your project and generate a key in your .env file您必须为您的项目提供读写权限并在您的 .env 文件中生成一个密钥

Run the following commands inside your project dir and you would be good to go :在您的项目目录中运行以下命令,您会很高兴:

$ sudo chmod -R 777 /storage /public /bootstrap

$ composer install

$ php artisan key:generate

I got this error after trying to start the dev server using php artisan serve This is how I resolved it:尝试使用php artisan serve启动开发服务器后出现此错误这是我解决的方法:

  1. Run composer install运行composer install

In case you get an error like "Your requirements could not be resolved to an installable set of packages", make sure you have the necessary extensions enabled in your php.ini config.如果您收到诸如“您的要求无法解析为一组可安装的软件包”之类的错误,请确保您在 php.ini 配置中启用了必要的扩展。 In my case I needed to enable extension=fileinfo在我的情况下,我需要启用extension=fileinfo

  1. Run composer update .运行composer update After this you should be able to start the server with no errors.在此之后,您应该能够无错误地启动服务器。

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

相关问题 Laravel 5无法打开所需的bootstrap /../ vendor / autoload.php CentOs - Laravel 5 Failed opening required bootstrap/../vendor/autoload.php CentOs LARAVEL:main():无法打开所需的“ vendor \\ autoload.php” - LARAVEL: main(): Failed opening required 'vendor\autoload.php' Laravel 5 打开失败需要引导程序/../vendor/autoload.php - Laravel 5 Failed opening required bootstrap/../vendor/autoload.php 打开失败需要&#39;../vendor/autoload.php&#39; - Failed opening required '../vendor/autoload.php' 无法打开“ PHPUnit / Autoload.php” - Failed opening 'PHPUnit/Autoload.php' Laravel(新手) - 无法加载autoload.php - Laravel (newbie) - Failed to load autoload.php Laravel PHP致命错误:require():必须打开失败…在第17行上的bootstrap / autoload.php - Laravel PHP Fatal error: require(): Failed opening required … bootstrap/autoload.php on line 17 Laravel 5.2 安装错误:需要打开失败../vendor/autoload.php - Laravel 5.2 Installation Error: failed opening required ../vendor/autoload.php 致命错误:require():在 Laravel 项目/Serpwow API 中打开所需的“vendor/autoload.php”失败 - Fatal error: require(): Failed opening required 'vendor/autoload.php' in Laravel project/Serpwow API 新的Laravel项目投掷500错误:require():打开所需的autoload.php失败 - New Laravel Project Throwing 500 Error: require(): Failed opening required autoload.php
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM