How to fix ‘Target class does not exist’ in Laravel 8

Posted by

In this tutorial im going to fix target class does not exist. Why its comes Target class does not exists — Its means in Route/web.php file you are not imported your controller name. first you have to import your controller name in web.php file. As define below.

1 step go to your controller file and check your controller name


namespace App\Http\Controllers;
use App\Http\Controllers\Controller;

use Illuminate\Http\Request;

class ContactController extends Controller
public function index(){
return view('contact');

2nd Step go to Route/web.php file and import your controller file name.


use Illuminate\Support\Facades\Route;
use App\Http\Controllers\ContactController;

| Web Routes
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!

Route::get('/', function () {
return view('welcome');

return view('about');

Route::get('contact', [ContactController::class, 'index']);

Now run this command in your terminal

php artisan serve

Now project run successfully.

Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x