在Laravel 4中路由到Controller失败 [英] Routing to Controller fails in Laravel 4

查看:64
本文介绍了在Laravel 4中路由到Controller失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Laravel 4中注册我的控制器.在routes.php中,我有:

I'm trying to register my controllers in Laravel 4. In routes.php I have:

Route::get("/","HomeController@index");
Route::get("search","SearchController@index");

现在,家用控制器路由很好,但是搜索控制器路由给我一个错误:

Now, the home controller route is fine, but the search controller route gives me an error:

ReflectionException: Class SearchController does not exist

但是,确实存在类 .我什至试图创建另一个示例控制器,但由于出现相同的消息而无济于事.

However, the class does exist. I even tried to create another sample controller, but to no avail, as the same message came up.

推荐答案

名称在L4中区分大小写.并且方法名称应该完全匹配(例如getIndex,而不是index()).

names are case sensitive in L4. And the method name should match exactly(e.g. getIndex, not index() ).

此外,因为它使用composer软件包,所以您需要运行: php composer dump-autoload 检测任何新的类/控制器

Also, because it uses composer packages, you will need to run: php composer dump-autoload to detect any new classes/controllers

这篇关于在Laravel 4中路由到Controller失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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