'my controller is not recognized and it actually exists why is this happening? [duplicate]

for some reason I get this error "Target class [web\HomeController] does not exist." saying that I don't have a controller but in fact I do and I don't understand why it appears

app\Http\Controllers\web\HomeController.php

<?php

namespace App\Http\Controllers\web;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

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

routes\web.php

<?php

use Illuminate\Support\Facades\Route;

Route::get('/', 'web\HomeController@home');


Solution 1:[1]

You should import the namespace or include the whole controller path in an array.

Route::get('/', [\App\Http\Controllers\web\HomeController::class, 'home']);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 batuzai04123