Controller target class does not exist?
P粉004287665
P粉004287665 2024-02-26 13:17:59
0
1
380

I'm trying to follow the Larva tutorial and make a controller. This is what I have so far, it works for the person in the video, but mine says the controller cannot be found. I don't know what to do to fix it. Thanks!

web.php file:

Route::get('/', [PagesController::class, 'home']);

PagesController.php file:

<?php

namespace App\Http\Controllers;

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




class PagesController extends Controller
{
    public function home() 
    {
        return view('welcome', [
            'foo' => 'bar'
        ]);
    }
}

PagesController.php file

error message

Web.php file

P粉004287665
P粉004287665

reply all(1)
P粉647504283

I think this is happening due to the route cache you added earlier

php artisan optimize:clear

Clear all cached commands

Then check if this get('/') route is bound to the home() method on the controller

php artisan route:list

I hope it solves your problem..

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template