简体   繁体   English

找不到类“App\\Http\\Controllers\\BaseController”

[英]Class 'App\Http\Controllers\BaseController' not found

Good day everyone, I'm new to laravel and i'm happy learning it.大家好,我是 Laravel 的新手,我很高兴学习它。 but i have the error written above.但我有上面写的错误。 I've searched stackoverflow faqs,devdocs, and others but no way out.我已经搜索过 stackoverflow 常见问题、开发文档和其他人,但没有出路。 while implementing my controller.在实现我的控制器时。 On the controller, i have this codes by default,在控制器上,我默认有这个代码,

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controlers;

class Controller extends BaseController
{
    use AuthorizesRequests, AuthorizesResources, DispatchesJobs, ValidatesRequests;
}

while in my controller, I have this code written在我的控制器中,我编写了这段代码

<?php


namespace App\http\Controllers;


class NiceActionController extends Controller
    {
    public function getNiceAction($action, $name = null){
        return view($action, ['name'=> $name]);
    }

    }

please how will i rectify the error.请问我将如何纠正错误。 Thanks in advance.提前致谢。

This is what your Controller should look like 这就是你的控制器应该是什么样子

The reason why it's broken is because you - or somebody who's working on this project - removed all of the use statements in this class.它被破坏的原因是因为您 - 或从事该项目的人 - 删除了该类中的所有use语句。 BaseController exists as a part of Laravel's internal Routing component. BaseController 作为 Laravel 内部路由组件的一部分存在。 The 'App\\Http\\Controllers\\BaseController' not found error you're seeing is because you're no longer referencing the class properly.您看到的'App\\Http\\Controllers\\BaseController' not found错误是因为您不再正确引用该类。

Under app/Http/Controllers/Controller.php, change it back to the following:在 app/Http/Controllers/Controller.php 下,改回如下:

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesResources;

class Controller extends BaseController
{
    use AuthorizesRequests, AuthorizesResources, DispatchesJobs, ValidatesRequests;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM