php artisan serve can't find the autoload.php
Solution 1
- First Install Composer: composer install.
- Then run a command in CMD prompt: composer dump-autoload.
Solution 2
Try running composer dump-autoload , after that run a composer install
If that doesn't work, try the composer update --no-scripts
Solution 3
I'm new to Laravel, and I got the same confusion with the command:
laravel new blog
There was no vendor folder.
But after I tried:
composer create-project --prefer-dist laravel/laravel blog
I found the vendor folder came up.
Don't know why either.
Related videos on Youtube
Charbel Sarkis
A Computer Science Student. Trying to teach myself data science (from books) books that i have read: learn python 3 the hard way Data Science From Scratch Python For Data Analysis Scikit-Learn cookbook books that i will read: The pragmatic programmer Clean Coder The Clean Coder Clean Architecture
Updated on June 04, 2022Comments
-
Charbel Sarkis almost 2 years
SOLUTION:
laravel new project-name
was actually giving me an error that i overlooked. I had the wrong version of php. It requires phpv7.1.3 or higher. If you don't have it it doesn't work.Ran into one other problem:
- i had a system environment variable that is pointing to an old version of php
- Also laravel requires openssl extension and mbstring to turned on. UNCOMMENTED from php.ini
FOR NEWCOMERS: if you have just downloaded php and unzipped the file. It contains a file called
install.txt
that you HAVE to read. It explains everything.
I ran
laravel new blog
from their getting started page. When I tried to runphp artisan serve
, I got the following error:Warning: require(C:\Projects\laravel-projects\blog/vendor/autoload.php): failed to open stream: No such file or directory in C:\Projects\laravel-projects\blog\artisan on line 18
The artisan file is pointing to
require __DIR__.'/vendor/autoload.php';
this directory does not exist. Even if I point it to the correct directory, it still wouldn't work because I don't have read permissions for that folder (so it gets denied).
What's going on, and how can I fix this?
EDIT: changed the url from the mentioned above to:
C:\Users\sarkis\AppData\Roaming\Composer\vendor\autoload.php
This worked perfectly for some reason. And NOW. A NEW ERROR HAS APPEARED.
Fatal error: Uncaught Error: Class 'Illuminate\Foundation\Application' not found in C:\Projects\laravel-projects\blog\bootstrap\app.php:14 Stack trace:#0 C:\Projects\laravel-projects\blog\artisan(21): require_once() #1 {main} thrown in C:\Projects\laravel-projects\blog\bootstrap\app.php on line 14
found that i don't have the proper version of php required.
-
Adam almost 6 yearsDid you run composer install?
-
Charbel Sarkis almost 6 yearsyes i did and the vendor file did not show up using windows 10 btw
-
Bart almost 6 years@CharbelSarkis Change permissions for your installation directory... You need to have, read, write, modify and for running locally execute also... Then run composer install and all should be fine...
-
Adam almost 6 yearsYou running WAMPP/XAMPP or ISS?
-
Charbel Sarkis almost 6 yearsWamp. I have wamp and xampp which should i use.
-
Niklesh Raut almost 6 yearsI think you are in windows OS ?
-
Charbel Sarkis almost 6 yearsyes @C2486 windows 10
-
Niklesh Raut almost 6 yearstry with
'\'
instead'/'
hererequire __DIR__.'\vendor\autoload.php';
-
Charbel Sarkis almost 6 yearsthat folder doesn't even exist. The problem is i have installed laravel globally. When you run
laravel new project
it doesn't make your vendor folder. I just tried installing laravel withoutglobal
and it worked
-
Charbel Sarkis almost 6 years
Generating optimized autoload files Class Illuminate\Foundation\ComposerScripts is not autoloadable, can not call post-autoload-dump script > @php artisan package:discover Fatal error: Class 'Illuminate\Foundation\Application' not found in C:\Projects\laravel-projects\blog\bootstrap\app.php on line 14 Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255
-
Charbel Sarkis almost 6 yearsthis is the error that i got from
composer dump-autoload
-
Charbel Sarkis almost 6 years
php artisan serve
after running this commandFatal error: Class 'Illuminate\Foundation\Application' not found in C:\Projects\laravel-projects\blog\bootstrap\app.php on line 14
-
Mateusz Drost almost 6 yearsHe uses Windows.
-
Charbel Sarkis almost 6 yearsi do have permissions for the files it's just that the vendor folder doesn't exist and even if it did the actual folder that this needs is located in appdata/...../vendor/autoload
-
Charbel Sarkis almost 6 yearsThis doesn't change anything the file still points to an empty directory. Had to change the url to the correct one and got a new error
-
Charbel Sarkis almost 6 yearsi have composer. that's how i installed laravel composer global require laravel/installer
-
Nico Bistolfi almost 6 yearsCheck this post then -> stackoverflow.com/questions/29764368/…
-
arm almost 5 years@Charbel Well that command won't install composer as of course you didn't expect to be able to install composer via composer, did you? That will install all the "dependencies" for your project that are missing for some reason, using composer and the
composer.json
file in root path of your project. So just do this: In the root path of your project, runcomposer install
. Remember you have to run this in the path that thecomposer.json
file of your project is located which in this case, will always be the root dir of your laravel project. It will download and install all the dependencies. Y -
Charbel Sarkis almost 5 years@arm That wasn't the problem. Apparently laravel requires php 7.2 from that point in time. And i had a much older version.