How to Solve Target Class Does Not Exist In Laravel

Hello Artisan

In this tutorial i will explain how we can solve target class does not exist in laravel 8. You know recently laravel 8 was released some days ago. They changed the routing system a bit from other s version of laravel.

In this tutorial we will solve laravel 8 routing problem like target class apphttpcontrollers does not exist. See the below code to solve this BindingResolutionException Target class does not exist.

Example code : 

use App\Http\Controllers\TestController;

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


So in Laravel 8 you have to show the path of your controller. You can use route groupe to avoid path as like below.

Route::namespace('App\Http\Controllers')->middleware('guest')->group(function () {
    Route::prefix('')->group(function () { //you can use prefix if you want
      Route::get('/', 'TestController@index');


Or if your are not happy with the above system and you would like to use it like laravel 7 then follow the below tips. go to your route service provider and update the code like below.


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

// the add this namespace like below

 $this->routes(function () {


now you can simply use like laravel 7 or other version

Route::get('/', 'TestController@index');


Hope it can help you.


Facebook Github
A web enthusiastic, a self-motivated full-stack software engineer from Dhaka, Bangladesh with experience in developing applications using Laravel , React and Vue js