Laravel says the class Laravel\Fortify\Features cannot be found
Error Class "Laravel\Fortify\Features" not foundShort answer
Laravel\Fortify\Features is a class inside the laravel/fortify package, and config/fortify.php imports it. When PHP cannot load it, either the package is not in vendor/ (never required, or skipped by --no-dev), or the autoloader cannot map the name (a stale authoritative classmap, or a name spelled with the wrong letter case on Linux).
Fix it fast
1Find out which cause you have
Ask the disk whether the class file is there. If the file is missing, the package is not installed here. If it is there, the autoloader is the problem.
ls vendor/laravel/fortify/src/Features.php grep -n "fortify" composer.json2Match what you see, then jump to its fix
- 1
ls reports no such file, and composer.json has no laravel/fortify linelaravel/fortify was never installed in this projectFix - 2
It works on your machine and fails only after a deploy that runs composer install --no-devThe package sits in require-dev and production installs with --no-devFix - 3
The file exists under vendor/laravel/fortify/src, yet the check prints bool(false), and the deploy script uses --classmap-authoritative or -aAn authoritative classmap was built before the package was addedFix - 4
The app works on macOS or Windows and fails on a Linux server or in DockerThe name is spelled with different letter case and the server is LinuxFix
- 1
What does the error look like?
Error Class "Laravel\Fortify\Features" not foundClass "Laravel\Fortify\Features" not found
Cause 1 of 4
laravel/fortify was never installed in this project
1Check
config/fortify.php (or app/Providers/FortifyServiceProvider.php) can exist without the package. That happens when files are copied from another project, or a branch is merged without its composer.json change. Fortify is a separate Composer package, not part of the framework.
composer show laravel/fortify
ls config/fortify.php app/Providers/FortifyServiceProvider.php2Fix
Require the package. If composer.json already lists it and only vendor/ is stale, composer install is enough.
composer require laravel/fortify
# only when composer.json and composer.lock already list it:
composer install3Verify
Fortify registers its routes once it loads, so route:list now shows them and the class error is gone.
php artisan route:listConfirmed by laravel.com
Cause 2 of 4
The package sits in require-dev and production installs with --no-dev
1Check
--no-dev skips every package under require-dev. If laravel/fortify is listed there, the production vendor/ folder never receives it, while config/fortify.php still imports its class.
grep -n -E '"require(-dev)?"|laravel/fortify' composer.json2Fix
Move the laravel/fortify line from require-dev into require in composer.json, then update just that package so composer.lock follows. Commit both files and deploy again.
composer update laravel/fortify
composer install --no-dev3Verify
The class file now exists in a no-dev install.
ls vendor/laravel/fortify/src/Features.phpConfirmed by getcomposer.org
Cause 3 of 4
An authoritative classmap was built before the package was added
1Check
With an authoritative classmap Composer trusts the map only: a class that is not in it does not exist, and the PSR-4 folders are never searched. A map generated before Fortify arrived has no entry for it.
grep -rn -E "classmap-authoritative|optimize-autoloader" composer.json Dockerfile 2>/dev/null
php -r 'require "vendor/autoload.php"; var_dump(class_exists("Laravel\\Fortify\\Features"));'2Fix
Regenerate the autoloader with the same flags your deploy uses. Do this on every deploy, after composer install.
composer dump-autoload --classmap-authoritative3Verify
PHP can now load the class, so the check prints bool(true).
php -r 'require "vendor/autoload.php"; var_dump(class_exists("Laravel\\Fortify\\Features"));'Confirmed by getcomposer.org
Cause 4 of 4
The name is spelled with different letter case and the server is Linux
1Check
PHP class names ignore case, but PSR-4 maps a name to a file path, and Linux file systems do not. A line such as use Laravel\Fortify\features; asks for src/features.php, which does not exist. List how the name is written in your own code.
grep -rn -i 'fortify\\features' config app routes bootstrap2Fix
Write the name exactly as the package spells it: Laravel\Fortify\Features, with the capital letters shown.
<?php
use Laravel\Fortify\Features;3Verify
Fortify loads again, and its routes show up in the list.
php artisan route:listConfirmed by php-fig.org
How do I stop it coming back?
- Commit composer.lock together with composer.json, and run composer install (not update) on servers.
- Keep packages that config files import in require, never in require-dev.
- Run composer dump-autoload with the same flags in every deploy, right after composer install.
- Develop on a case-sensitive file system (Linux container or Sail), so spelling mistakes show up before release.
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 says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fixBack 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 fixBack end
composer install says the lock file is not compatible and asks for update
Your lock file does not contain a compatible set of packages. Please run composer update.
composer install checked the locked packages against this machine's PHP and extensions and found a conflict.
3 causes, each with a fixBack 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 fixBack end
composer require laravel/passport stops with 'requirements could not be resolved'
... but these were not loaded, likely because it conflicts with another require.
Composer found no Passport release that fits your project at once.
4 causes, each with a fixBack end
Composer says the root composer.json requires a PHP version your PHP does not satisfy
Your requirements could not be resolved to an installable set of packages.
Composer compares the php constraint in your composer.json, or in a package, with the PHP that runs Composer.
3 causes, each with a fix