douyi3767 2017-12-04 09:10 采纳率: 0%
浏览 4153

如何解决致命错误:找不到类'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 09: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

    评论

报告相同问题?