Laravel: Target class [App\Http\Controllers\X] does not exist.
Laravel’s container couldn’t find the controller or class named in a route or binding.
Target class does not exist Meaning
Since Laravel 8 route strings aren’t automatically prefixed with the controller namespace. Typos, wrong namespaces, missing use statements and stale autoload maps all cause it.
Common causes
- Route uses 'UserController@index' string syntax without namespace (Laravel 8+)
- Class/namespace typo
- File name case differs from class name
- Autoload not regenerated
⚡ Quick fix
- Use the class syntax:
[UserController::class, 'index']with auseimport - Check namespace and file name case
composer dump-autoload
Detailed fix by platform
PHP
Route::get('/users', [\App\Http\Controllers\UserController::class, 'index']);
How to diagnose
- Class — Exact class string in the message
- File — Does it exist at the PSR-4 path?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in PHP
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 13 Oct 2026