Target class does not exist in Laravel 8

In Laravel, the error “Target class does not exist” typically occurs when the framework is unable to locate the specified class, often due to incorrect namespaces or class names. Here’s how you can fix this error in Laravel 8.

Step 1:-

<?php

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

use Illuminate\Http\Request;

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

Step 2:- Route/web.php

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

run command in your terminal –

php artisan serve

Output:-

Hopefully, It will help you ….!!!

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x