php artisan serve can't find the autoload.php

15,662

Solution 1

  1. First Install Composer: composer install.
  2. 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.

Share:
15,662

Related videos on Youtube

Charbel Sarkis
Author by

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, 2022

Comments

  • Charbel Sarkis
    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 run php 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
      Adam almost 6 years
      Did you run composer install?
    • Charbel Sarkis
      Charbel Sarkis almost 6 years
      yes i did and the vendor file did not show up using windows 10 btw
    • Bart
      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
      Adam almost 6 years
      You running WAMPP/XAMPP or ISS?
    • Charbel Sarkis
      Charbel Sarkis almost 6 years
      Wamp. I have wamp and xampp which should i use.
    • Niklesh Raut
      Niklesh Raut almost 6 years
      I think you are in windows OS ?
    • Charbel Sarkis
      Charbel Sarkis almost 6 years
      yes @C2486 windows 10
    • Niklesh Raut
      Niklesh Raut almost 6 years
      try with '\' instead '/' here require __DIR__.'\vendor\autoload.php';
    • Charbel Sarkis
      Charbel Sarkis almost 6 years
      that 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 without global and it worked
  • Charbel Sarkis
    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
    Charbel Sarkis almost 6 years
    this is the error that i got from composer dump-autoload
  • Charbel Sarkis
    Charbel Sarkis almost 6 years
    php artisan serve after running this command Fatal error: Class 'Illuminate\Foundation\Application' not found in C:\Projects\laravel-projects\blog\bootstrap\app.php on line 14
  • Mateusz Drost
    Mateusz Drost almost 6 years
    He uses Windows.
  • Charbel Sarkis
    Charbel Sarkis almost 6 years
    i 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
    Charbel Sarkis almost 6 years
    This 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
    Charbel Sarkis almost 6 years
    i have composer. that's how i installed laravel composer global require laravel/installer
  • Nico Bistolfi
    Nico Bistolfi almost 6 years
  • arm
    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, run composer install. Remember you have to run this in the path that the composer.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
    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.