找不到基本控制器 Laravel PHP


base controller not found laravel php

<?php namespace vendor'laravel'framework'src'Illuminate'Support'Facades;
use DB;
use BaseController;
class ModuleController extends BaseController{
    public function index()
    {
        //Display data from students table.
        $data=DB::connection('mysql')->select('select * from students');
    }
}

错误消息:致命错误:在第 6 行的 C:''xampp''htdocs''laravel''test.php 中找不到类"基本控制器"

你需要改变

use BaseController;

use Illuminate'Routing'Controller as BaseController;

此外,您将遇到错误 DB .您需要使用

use Illuminate'Support'Facades'DB;

而不是

use DB;

也是命名空间:)

namespace App'Http'Controllers;

而不是

namespace vendor'laravel'framework'src'Illuminate'Support'Facades;

在使用 Laravel 之前,尝试学习一些 OOP 基础知识。

您可以让工匠为您创建每个控制器,例如:

$ sudo php artisan make:controller ModuleController

他照顾一切。您可以看到工匠可以为您提供的所有服务:

$ sudo php artisan