Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Laravel says the Application class is not found when you run artisan or open the site

ErrorClass "Illuminate\Foundation\Application" not found

Short answer

Laravel's core class lives in vendor/laravel/framework, so this error means Composer's autoloader does not know the framework. Either the vendor folder was never installed on this machine, or the autoloader was generated for different files. Run composer install, then composer dump-autoload.

  • Applies to Laravel 12, PHP 8.3, Composer 2.8
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check whether the framework is on disk at all.

    ls vendor/laravel/framework/src/Illuminate/Foundation/Application.php
  2. 2Match what you see, then jump to its fix

    1. 1ls says 'No such file or directory' for the framework filevendor/ was never installed on this machineFix
    2. 2The framework file exists, but the class is still not found, often after copying vendor from another machine or after a partial updateThe generated autoloader is out of date or sealed to an old classmapFix

What does the error look like?

  • Class "Illuminate\Foundation\Application" not found
  • Fatal error: Class 'Illuminate\Foundation\Application' not found in bootstrap/app.php
  • Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found

Cause 1 of 2

vendor/ was never installed on this machine

1Check

Composer's docs advise adding vendor to .gitignore, so a fresh clone or an upload of the code without that folder has no framework. Only composer.json and composer.lock are committed.

ls vendor | head
git check-ignore vendor

2Fix

Run install in the project root. It brings vendor/ in line with composer.lock. On a production server add the usual flags.

composer install
# production:
composer install --no-dev --optimize-autoloader

3Verify

The file exists and artisan starts.

ls vendor/laravel/framework/src/Illuminate/Foundation/Application.php
php artisan --version

Confirmed by getcomposer.org

Did this fix it?

Cause 2 of 2

The generated autoloader is out of date or sealed to an old classmap

1Check

The autoloader files in vendor/composer are generated. With --classmap-authoritative, classes load only from the classmap, so anything missing from it is reported as not found.

grep -c "Illuminate\\\\Foundation\\\\Application" vendor/composer/autoload_classmap.php

2Fix

Regenerate the autoloader.

composer dump-autoload

3Verify

Start artisan again.

php artisan --version

Confirmed by getcomposer.org

Did this fix it?

How do I stop it coming back?

  • Make composer install a fixed step of every deploy and of every fresh clone.
  • Never copy vendor between machines with different PHP versions; install on the target.
  • Keep vendor in .gitignore, as Composer advises, and commit composer.lock.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

composer require maatwebsite/excel fails to install

Composer says the package needs an older PHP than the one installed

Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.

3 causes, each with a fix

Back end

composer require laravel/horizon fails: ext-pcntl is missing

laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system

Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.