Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed Opening autoload.php in Laravel 5

I have recently installed Laravel via Composer but I keep get the following error:

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

Am I missing something? Because I followed it step by step.

enter image description here

like image 585
Chew Halo Avatar asked Jan 04 '19 04:01

Chew Halo


3 Answers

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. The vendor directory contains your Composer dependencies.

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.

like image 103
Udhav Sarvaiya Avatar answered Oct 15 '22 02:10

Udhav Sarvaiya


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

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

BUT IF NOT IF WILL OCCUR 404 IN SOME CASES

this is Just For Example

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

enter image description here

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

enter image description here

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

enter image description here

step4: open your index.php file and make the following changes

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

here is my cpanel server directory structure

hope it helps if the answer is not clear please comment below if the error continues

enter image description here

like image 37
ManojKiran Appathurai Avatar answered Oct 15 '22 02:10

ManojKiran Appathurai


Run composer with --no-scripts

composer update --no-scripts  

This shall fix the issue.

like image 21
Bhautik Jethva Avatar answered Oct 15 '22 04:10

Bhautik Jethva