Target class [MyController] does not exist in Laravel

Hello, in this tutorial, we will show you how to resolve the “Target class [MyController] does not exist” error in Laravel. Although it’s a small error, it can be frustrating to encounter. This error often arises when creating a new controller and adding a view page.

Target class [] does not exist in Laravel

The main reason for this error is that the controller class has not been imported in the route file.

Therefore, to fix the issue, you need to ensure that the controller class is imported using the “use” statement at the top of your route file. Simply open your “web.php” file and add the necessary “use” statement to import the controller class.

use App\Http\Controllers\myController;

Route::get('/', [myController::class, 'myFunction']);

Leave a Reply