Target class does not exist PHP Origin: Application & API OSI layer 7 · Application Last updated 13 Oct 2026

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.

Exact message you may see Target class does not exist
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

  1. Use the class syntax: [UserController::class, 'index'] with a use import
  2. Check namespace and file name case
  3. composer dump-autoload

Detailed fix by platform

PHP

  1. Route::get('/users', [\App\Http\Controllers\UserController::class, 'index']);

How to diagnose

  1. Class — Exact class string in the message
  2. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

403 This action is unauthorized — Laravel: Illuminate\Auth\Access\AuthorizationException: This action is unauthorized. (Laravel)403 This action is un…419 Page Expired — Laravel: 419 Page Expired (CSRF token mismatch) (PHP)419 Page ExpiredAttempt to read property "x" on null — Laravel/PHP 8: ErrorException: Attempt to read property "name" on null (Laravel)Attempt to read prope…Class "App\Models\X" not found — Laravel: Error: Class "App\Models\Post" not found (Laravel)Class "App\Models\X" …Class not found — PHP Fatal error: Uncaught Error: Class "X" not found (PHP)Class not foundCommand "x" is not defined — Laravel: Symfony\Component\Console\Exception\CommandNotFoundException: Command "make:livewire" is not defined. Did you mean one of these? (Laravel)Command "x" is not de…Laravel storage — Laravel: The stream or file "storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied (PHP)Laravel storageLaravel table not found — Laravel: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db.sessions' doesn't exist (PHP)Laravel table not fou…Target cl…

Explore the map of this error Full error map →

🧠 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.