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.
Seen on:
PHP
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 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026