douyi3767 2017-12-04 01:10 采纳率: 0%
浏览 4137

如何解决致命错误:找不到类'App \ Http \ Controllers \ Controller'

我正在尝试使用Laravel 5.4将表单提交到数据库,但是每次我按下“提交”按钮时,都会出现以下错误消息:

Fatal error: Class 'App\Http\Controllers\Controller' not found.

下面是我的代码controller.php:

<?php

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

class PagesController extends Controller
{
    public function index()
    {
        return view('./');
    }

    public function about()
    {
        $title='About us';
        return view('pages.about')->with('title',$title);
    }

    public function services()
    {
        $data=array(
            'title'=>'Services',
            'services'=>['Mechanic help','book a mechanic','others']
        );
        return view('pages.services')->with ($data);
    }

    public function create()
    {

    }
}

展开全部

  • 写回答

2条回答 默认 最新

  • duanjia2772 2017-12-04 01:19
    关注

    That kind of error would mean that you are either missing your Controller.php file in the same folder, or the autoloader isn't loading it, or it is not defining the class Controller. This is the file in the Laravel repo:

    https://github.com/laravel-shift/laravel-5.4/blob/master/app/Http/Controllers/Controller.php

    评论
  • douji1999 2017-12-04 02:00
    关注

    Fatal error: Class 'App\Http\Controllers\Controller' not found.

    This error could only mean that you are missing this class. Make sure that you have a Controller.php in the same folder with your PagesController.php. Also, kindly check if you are using the right namespace and be strict with capitalizations.

    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部