[Solved] Target class Controller does not exist.

Brijpal Sharma
laravel   Publish on:-September 30th, 2020 , Category:- Web Development

"Target class Controller does not exist" issue comes in Laravel 8. One simple trick can solve this issue.

This error comes in Laravel new version because there is no namespace prefix being applied to your route groups that your routes are loaded into. In the old version of Laravel, the RouteServiceProvider contained a $namespace property. In the old version property's value would automatically be prefixed onto the controller route.

So to solve this issue 

We need to Fully Qualify Class Name for your Controllers which is you are going to use. Or if you are using the class name at the top you must be used the namespace prefix.

use App\Http\Controllers\PageController;

Route::get('/page', [PageController::class, 'index']);
// or
Route::get('/page', 'App\Http\Controllers\[email protected]');


Another way to solve 

Define namespace in RouteServiceProvider as an old version. 


public function boot()

        $this->routes(function () {
                ->namespace('App\Http\Controllers')  <------------ Add this

                ->namespace('App\Http\Controllers') <------------- Add this


So here we solve this issue Target class Controller does not exist in Laravel 8.

Brijpal Sharma

Hello, My Name is Brijpal Sharma. I am a Web Developer, Professional Blogger and Digital Marketer from India. I am the founder of Codermen. I started this blog to help web developers & bloggers by providing easy and best tutorials, articles and offers for web developers and bloggers...


Generic placeholder image

Publish on:-November 17th, 2020
Thanks for the information, it's works. My name is Jihan, i am from Indonesia. I am new in web developer.

You must be logged in to post a comment.