How to Solve Target Class Does Not Exist In Laravel

Hello Web lover’s
Today In this tutorial i will explain and show you how we can solve target class does not exist in laravel 8 application. We know recently laravel 8 was released few days ago. They are changed the routing system a bit from other’s version of laravel application.i will show you how to Solve Target Class Does Not Exist problem solve.

Now in this tutorial we will solve laravel 8 routing problem as like as target class app/http/controllers does not exist. So let’s start and see the below code to solve this Binding/Resolution/Exception Target class does not exist problem.

Example code: 

use App\Http\Controllers\TestController;

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

So in Laravel 8 we have to show the path of our controller. Now we can use route group to avoid the path as like belows code.

Read Also : Ajax CRUD with Laravel 8 Tutorial with Example for Beginners

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 we are not happy with the above system and then we will like to use it like laravel 7 or more then we can follow the below tips. So let’s go to your route service provider and update the code like below code.


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

// the add this namespace like below

 $this->routes(function () {

So now we can simply use this on like laravel 7 or other version

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

Read Also : Laravel 8 Mobile Number Verification Tutorial

thanks for reading i hope you will get help from hers.For better know you can follow on our facebook

Shahriar Sagor

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.