S
S
supercoder6662020-10-09 11:21:40
Laravel
supercoder666, 2020-10-09 11:21:40

How to solve the problem with “Target class does not exist” in Laravel?

Faced such a problem. Created a controller through the console using artisan, everything was created successfully. However, when I bind this controller to the route, the Target class [PageController] does not exist error occurs .
HNeoM.png
web.php:

Route::get('/', [PageController::class, 'home'])->name('home');

PageController:
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PageController extends Controller {

    public function home() {
        return view('home');
    }
    
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2020-10-09
@supercoder666

Route::get('/', [\App\Http\Controllers\PageController::class, 'home'])->name('home');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question