DEV Community 👩‍💻👨‍💻

Techsolutionstuff
Techsolutionstuff

Posted on • Originally published at techsolutionstuff.com

Target Class Does Not Exist In Laravel 8

In this example we will learn about target class does not exist in laravel 8. In laravel 8 you can see there are many changes and updates. Many laravel users are facing issue in their new laravel 8 version when they try to load their routes in web.php and they run into an Exception that says something like "Target class [postController] does not exist".

You will get like IlluminateContractsContainerBindingResolutionException Target class does not exist, laravel target class does not exist, Target class AppHttpMiddlewareHandleInertiaRequests does not exist, Target class (PostController) does not exist, controller does not exist laravel 8.

So, let's see how to fix target class does not exist in laravel 8.

Upto Laravel 7, the RouteServiceProvider.php file had the below code:

here, namespace variable has stored 'App\Http\Controllers' and declered in middleware and prefix route as below.

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

protected function mapWebRoutes()
{
    Route::middleware('web')
        ->namespace($this->namespace)
        ->group(base_path('routes/web.php'));
}

protected function mapApiRoutes()
{
    Route::prefix('api')
        ->middleware('api')
        ->namespace($this->namespace)
        ->group(base_path('routes/api.php'));
}
Enter fullscreen mode Exit fullscreen mode

Read More : Target Class Does Not Exist In Laravel 8

Top comments (0)

Join us at DEV Want to join the conversation?
 

It's easy! Become a DEV member to follow this post, comment, and more.