Im starting to programming in Laravel and trying to understood how the routes works. But it always said that the class "UserControler" that I just created it doesn't exist and I don't know why.
Routes > web.php
<?php
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| 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('/user',[UserController::class, 'index']);
I have this in the controllers directory that I just made with the artisan. app>http>controller>UserController.php
<?php
namespace App\Http\Controllers;
class UserController extends Controller
{
public function index()
{
return "Hello World!";
}
}
I get this error:
BindingResolutionException PHP 8.1.4 9.9.0 Target class [UserController] does not exist.