Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Target class [HomeController] does not exist

Target class [HomeController] does not exist.

i’m using laravel in web.php i have this code :

Route::get('/home','HomeController@home' )->name('home');
Route::get('/about','HomeController@about' )->name('about');

in file homeController.php :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    //
    public function home(){
        return view('home');
    }
}

>Solution :

What version of Laravel are you using? If you are using Laravel 10 (the latest), you should import the controller and use it like this:

use App\Http\Controllers\UserController;
 
Route::get('/user/{id}', [UserController::class, 'show']);

You can read more in details in the official documentation here: https://laravel.com/docs/10.x/controllers#basic-controllers

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading