IT & Programming

Laravel 8 Target class [Controller] does not exist.

In laravel 8.x, there is no namespace prefix applied to routes.

In previous version of laravel you could use:

Route::get('/products', [ProductController::class, 'index']);

or

Route::resource('products', 'ProductController');

Where you don't need to specify App\Http\Controllers

If you want to do it old way then go to App\Provides\RouteServiceProvider.php and uncomment

protected $namespace = 'App\\Http\\Controllers';

Don't forget to run "php artisan optimize" after the change.

Leave A comment

Email address is optional and will not be published. Only add email address if you want a reply from blog author.
Please fill required fields marked with *