# Laravel: Target class [App\Http\Controllers\X] does not exist.

**Code:** `Target class does not exist` · **Category:** PHP · **Seen on:** PHP

Laravel’s container couldn’t find the controller or class named in a route or binding.

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/php/laravel-target-class-does-not-exist)
