Solution: Laravel Target class does not exist Error
👤 By Webune | 📆
When I sent this command I got an error:
$ sail artisan route:list
Illuminate\Contracts\Container\BindingResolutionException
Target class [app/Http/Controllers/API/AuthController] does not exist.
at vendor/laravel/framework/src/Illuminate/Container/Container.php:832
This is how my code looked like:
Route::post('/register', 'API/AuthController@register');
Route::post('/login', 'API/AuthController@login');
Route::apiResource('/ceo', 'API/CEOController')->middleware('auth:api');
Solution:
This is how it should look like:
Route::post('/register', [AuthController::class, 'register']);
// or
Route::post('/login', 'App\Http\Controllers\API\AuthController@login');
// or
Route::apiResource('/ceo', 'App\Http\Controllers\API\CEOController')->middleware('auth:api');
For more help on this message, you can go to where I found the solution:
# NEW WAY LARAVEL 8
Source: https://stackoverflow.com/questions/63807930/target-class-controller-does-not-exist-laravel-8
Hope the helps: