Target class controller does not exist – Laravel 8

In previous releases of Laravel, the RouteServiceProvider contained a $namespace property. This property’s value would automatically be prefixed onto controller route definitions and calls to the action helper / URL::action method. In Laravel 8.x, this property is null by default. This means that no automatic namespace prefixing will be done by Laravel.

Laravel 8.x Docs – Release Notes

You need to use the Fully Qualified Class Name for your Controllers when referring to them in your routes when not using the namespace prefixing.

use App\Http\Controllers\UserController;

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

Leave a Reply

Your email address will not be published. Required fields are marked *