Fatal error: Class 'Illuminate\Foundation\Application' not found

144,989

Solution 1

In my situation, I didn't have the full vendor dependencies in place (composer file was messed up during original install) - so running any artisan commands caused a failure.

I was able to use the --no-scripts flag to prevent artisan from executing before it was included. Once my dependencies were in place, everything worked as expected.

composer update --no-scripts

Solution 2

Just in case I trip over this error in 2 weeks again... My case: Checkout an existing project via git and pull in all dependencies via composer. Came down to the same error listed within the title of this post.

Solution:

composer dump-autoload
composer install --no-scripts

make sure everything works now as expected (no errors!)

composer update

Solution 3

Something is clearly corrupt in your Laravel setup and it is very hard to track without more info about your environment. Usually these 2 commands help you resolve such issues

php artisan clear-compiled
composer dump-autoload

If nothing else helps then I recommend you to install fresh Laravel 5 app and copy your application logic over, it should take around 15 min or so.

Solution 4

In my case composer was not installed in that directory. So I run

composer install

then error resolved.

or you can try

composer update --no-scripts
cd bootstrap/cache/->rm -rf *.php
composer dump-autoload

Solution 5

I had accidentally commented out:

require __DIR__.'/../bootstrap/autoload.php';

in /public/index.php

When pasting in some debugging statements.

Share:
144,989
xenish
Author by

xenish

Updated on July 05, 2022

Comments

  • xenish
    xenish almost 2 years

    I am getting following error when I open my site which is made using laravel 5

    Fatal error: Class 'Illuminate\Foundation\Application' not found in C:\cms\bootstrap\app.php on line 14

    I have tried removing vendor folder and composer.lock file and running composer install it's not working I tried running PHP artisan optimize but it shows error

    Fatal error: Class'Illuminate\Foundation\Application' not found

    Is there any way to solve this problem?

    Edited: This problem aroused as soon as I used the php artisan make:model Page command which did create the model but then the above error gets displayed when I access the site Also If use the Laravel's Local Development Server no such problem arises only if I use wamp server

  • Jnanaranjan
    Jnanaranjan almost 9 years
    +1 Worked for me. In my case I have included other required packages separately in the composer.json file. This helped me.
  • Migerusantte
    Migerusantte over 6 years
    This should be the accepted answer, was going around this for about two hours, trying other answers from stack, but this totally solved it. Easy and to the point. Thanks
  • Kevin Pajak
    Kevin Pajak almost 6 years
    Also worked for me using "composer update --no-scripts" (after running "composer dump-autoload")
  • Adolfo Gomez Nasol
    Adolfo Gomez Nasol over 5 years
    This works for me, encounter this issues after migrating Laravel website to another server
  • Paulo Boaventura
    Paulo Boaventura almost 3 years
    Your answer must have an interpretive example along with your code, after all this question is old ...