close

[Solved] Target class controller does not exist in Laravel 8

Hello Guys, How are you all? Hope You all Are Fine. Today I am trying to make routing but I am facing following error Target class controller does not exist in Laravel 8. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Target class controller does not exist in Laravel 8 Error Occurs ?

I am trying to make routing but I am facing following error in my laravel 8.

Target class [Api\RegisterController] does not exist.

How To Solve Target class controller does not exist in Laravel 8 Error ?

  1. How To Solve Target class controller does not exist in Laravel 8 Error ?

    To Solve Target class controller does not exist in Laravel 8 Error In Laravel 8 You have to use Route as given Below: Route::get('/register', 'App\Http\Controllers\[email protected]'); OR use App\Http\Controllers\UserController; Route::get('/register', [UserController::class, 'register']); Now, your error must be solved.

  2. Target class controller does not exist in Laravel 8

    To Solve Target class controller does not exist in Laravel 8 Error In Laravel 8 You have to use Route as given Below: Route::get('/register', 'App\Http\Controllers\[email protected]'); OR use App\Http\Controllers\UserController; Route::get('/register', [UserController::class, 'register']); Now, your error must be solved.

In Laravel 8 You have to use Route as given Below.

Route::get('/register', 'App\Http\Controllers\[email protected]');

OR

use App\Http\Controllers\UserController;

Route::get('/register', [UserController::class, 'register']);

Now, your error must be solved.

Solution 2: uncomment this line

Just uncomment This line in your app\Providers\RouteServiceProvider.php path and remove the comment of this line.

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

Now, you can use old routing method in your laravel 8.

Summary

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you?

Also, Read

Please Rate Our Solution to Motivate Us For Give Our Best

Leave a Comment