Laravel Controller不存在,即使它显然存在 [英] Laravel Controller doesn't exist, even though it clearly exists

查看:87
本文介绍了Laravel Controller不存在,即使它显然存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到的错误是即使我知道控制器也不存在,这是代码.

The error I'm getting is that the controller doesn't exist even though I know it does, here's the code.

Route.php

Route.php

Route::get('mdpay/template', array("uses" => "templateController@index"));

templateController.blade.php

templateController.blade.php

class templateController extends BaseController {

  public function index()
  {
    echo "made it";
  }


}

为什么会出现此错误:类TemplateController不存在

Why might I be getting this error: Class TemplateController does not exist

=================更新:=================

================= UPDATE: ==================

好吧,所以我创建了正确的路由,重命名了文件,并更正了类名,但我仍然遇到该错误.

Ok, so I've created the correct route, renamed my file, and corrected the class name and I'm still coming up with that error.

文件名:

templateController.php

templateController.php

// File Name: TemplateController.php
class TemplateController extends BaseController {
    public function index()
    {
        // app/views/myView.blade.php
        echo "hello";
    }
}

我的路线是:

Route::get('mdpay/template', array("uses" => "TemplateController@index"));

仍收到控制器不存在错误.除此控制器外,我所有其他控制器(其他3个)都在工作.

Still receiving Controller Doesn't Exist error. All my other controllers (3 others) are working except this one.

推荐答案

如果使用的是标准作曲家classmap自动加载器,则每次创建新文件时都需要composer dumpautoload.

If you are using the standard composer classmap autoloader you need to composer dumpautoload everytime you create a new file.

因此,要使用Laravel给出的标准作曲家设置来创建新的控制器:

So to create a new controller with the standard composer setup given by Laravel:

  1. app/controllers中创建一个名为TemplateController.php
  2. 的新文件
  3. 打开终端并运行composer dumpautoload
  1. Create a new file in app/controllers named TemplateController.php
  2. Open up terminal and run composer dumpautoload

如先前的用户所述,仅查看文件应以.blade.php结尾.

这篇关于Laravel Controller不存在,即使它显然存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆