Home > Net >  Controller Target Class does not exist?
Controller Target Class does not exist?

Time:05-07

Im trying to follow a larval tutorial and make a controller. This is what I have so far and it works for the guy in the video but mine says controller not found. I don't know what to do to fix it. Thank you!

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

CodePudding user response:

why did you use this in PagesController.php :

use App\Http\Controllers\PagesController;

This is wrong. you must remove this line of code in PagesController.php

CodePudding user response:

Do you have use App\Http\Controllers\PagesController in web.php file?

If it doesn't exist, you should type it top of the file.

  • Related