问题描述
我试图从使用代码igniter切换到laravel然而我注意到,在每一个教程,我遵循,我们总是在route.php中laravel声明路由不像代码igniter它有一个默认路由像 http:// localhost / projname / controller / method
。有一个方法可以有一个自动路由像CI或我只是错过了laravel路由规则中的一些东西这是非常重要的,因为我们都知道大网站有超过50个链接,如果我们要声明这些都在laravel的routes.php。
为什么是有。在您的路由文件中 Route :: controller(Controller :: detect());
类确保每个函数名称与 action _
连接。所以如果你的函数名是 homepage()
,那么使它 action_homepage()
$请记住,您可以使用静态控制器名称
get_homepage()
和 post_homepage()
。但是你必须在你的控制器中声明这个类变量 public static $ restful = true;
Im trying to switch from using code igniter to laravel however I noticed in every tutorial I'd followed, we always declare the route in route.php in laravel unlike in code igniter that it has a default routing like http://localhost/projname/controller/method
. Is there a way to have an auto routing like CI or I'd just missed something in laravel routing rules?This is very important because we all know big websites have more than 50 links and it will be a hustle if we are going to declare those all in routes.php in laravel.
Why yes there is. In your route file do Route::controller(Controller::detect());
Now in your controller class make sure each function name is concatenated with action_
. So if your function name is homepage()
then make it action_homepage()
Keep in mind that you can use restful controller names get_homepage()
and post_homepage()
. But you'll have to declare this class variable in your controller public static $restful = true;
这篇关于laravel路由像代码点火器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!