[英]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
启动开发服务器后出现此错误这是我解决的方法:
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
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.