Hey @amoktar ,
Try running composer dumpautoload to rebuild your classpaths - that should, as long as the classes do exist, fix your issue.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello guys,
I'm having a laravel "laravel/framework": "^8.40",
with "laravel/passport": "^10.1", for authenticating api requests
and I'm using Postman
I noticed that if I did n't provide the Bearer Token with request to routes, protected with middleware (auth:api) I'm getting a 500 error and If I set the Bearer Token with the request everything goes well !
The same if the token was invalid, getting 500 error below
protected endpoint
Route::middleware('auth:api')->group(function () {
Route::get('/account', function (Request $request) {
return $request->user();
});
});
the error:
Illuminate\Contracts\Container\BindingResolutionException: Target class [App\Http\Controllers\Auth\LoginController] does not exist. in file C:\Users\AMoktar\Documents\code\project\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 875
Thanks
its trying to redirect you to login (which you don't have). Make sure you tell Laravel that you want a application/json response so that it returns the unauthenticated error to you and not a http redirect
make sure you set this Accept header in the postman headers with the request
Please or to participate in this conversation.