Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Poor_RJ's avatar

Illuminate  \  Contracts  \  Container  \  BindingResolutionException PHP 8.2.4 10.13.1 Target class [UserController] does not exist.

Composer provides a convenient, automatically generated class loader for | this application. We just need to utilize it! We'll simply require it | into the script here so we don't need to manually load our classes. | / require DIR.'/../vendor/autoload.php'; /

|--------------------------------------------------------------------------

Run The Application Once we have the application, we can handle the incoming request using the application's HTTP kernel. Then, we will send the response back to this client's browser, allowing them to enjoy our application. */ $app = require_once DIR.'/../bootstrap/app.php'; $kernel = $app->make(Kernel::class); $response = $kernel->handle(
$request = Request::capture()

)->send(); $kernel->terminate($request, $response);

0 likes
7 replies
Nakov's avatar

composer dump-autoload and make sure you are using the correct namespace in the controller. And correct import wherever you are referencing the controller.

Poor_RJ's avatar

@Nakov composer dump-autoload this is not working and checked namespace.still error given

Nakov's avatar

@Poor_RJ and the imports?

For example in your web.php file or whichever routes file you have UserController::class usage, do you have use App\Http\Controllers\UserController; at the top?

or at least in your RouteServiceProvider do you have: protected $namespace = 'App\Http\Controllers'; as long as that's your default namespace for your controllers?

Poor_RJ's avatar

@Nakov i already import the use App\Http\Controllers\UserController; in the top.

Nakov's avatar

@Poor_RJ if you share code, for example your controller and your routes, I might be able to help more.. But just guessing and then you just saying it is like that won't help :) Obviously there is something wrong since you get the error :)

Maybe it is UsersController instead of UserController maybe the file does not exists or it is named differently.. small letters instead of camel case. And many more issues that can be going on. But just it does not work does not leads to anything :)

Please or to participate in this conversation.