在 Laravel 5 中打开 autoload.php 失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/54033140/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed Opening autoload.php in Laravel 5
提问by Chew Halo
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
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
警告:需要(/home/leovoon/public_html/laravel-eee/bootstrap/../vendor/autoload.php):无法打开流:/home/leovoon/public_html/laravel-eee/bootstrap 中没有这样的文件或目录/autoload.php 第 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.
我错过了什么吗?因为我是一步一步来的。
回答by Udhav Sarvaiya
You got an error because you have missing vendor folderin your project, You need /vendor
because all your packages are there, including all the classes Laravel uses. The vendor directory contains your Composer dependencies.
你得到一个错误,因为你的项目中缺少vendor 文件夹,你需要,/vendor
因为你的所有包都在那里,包括 Laravel 使用的所有类。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 folderin your project and after that your project will start working normally.
使用此命令,您将在项目中重新创建vendor 文件夹,然后您的项目将开始正常工作。
回答by Manojkiran.A
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
注意:虽然这样做,你可能会遇到一些样式和JavaScript参考错误如果您USNIGASSET FUNCTION
没有必要担心
<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
如果答案不清楚,希望对您有所帮助,如果错误仍然存在,请在下方评论
回答by Bhautik Jethva
Run composer with --no-scripts
使用 --no-scripts 运行 composer
composer update --no-scripts
This shall fix the issue.
这将解决问题。
回答by Lizesh Shakya
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
回答by RonS
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