如何使用模块控制器在Kohana 3? [英] How to Use Module Controllers in Kohana 3?
问题描述
对于Kohana 3中/下的应用程序目录结构:
For the following application directory structure under / in Kohana 3:
-
应用程序
application
- 班
- 掌柜
- controller1.php
模组
- 管理
- class
- controller
- controller2.php
和/ admin / controller2?
And the urls be: /controller1 and /admin/controller2?
我似乎缺少一些东西,因为我不断收到404错误与/管理员/控制器。
I seem to be missing something though because I keep getting a 404 error with the /admin/controller. What am I doing incorrectly?
确切的错误是:
HTTP_Exception_404 [ 404]:在此服务器上找不到请求的网址管理员/借阅者。
HTTP_Exception_404 [ 404 ]: The requested URL admin/borrowers was not found on this server.
我没有任何自定义路线设置。这是一个非常简单的K3安装。
And I don't have any custom routes setup. This is a very vanilla K3 install at this point.
推荐答案
目录结构似乎有点。
使用模块不会自动意味着你有一个子目录。默认路由定义了以下url结构:
Using a module doesn't automatically means you have a subdirectory. The default route defines the following url structure:
/[controller]/[action]
所以对于给定的目录结构,您会得到以下结果:
So for the directory structure that you have given, you get the following:
/controller2/
操作可以省略,将默认为
index
。The action can be left out, but it will default to
index
.如果你想要一个特殊的管理子目录,你必须首先创建子目录你的模块类目录如下:
If you want a special admin subdirectory, you would first have to create that subdirectory in you modules classes directory like this:
/admin/classes/admin/controller2.php
然后你必须添加另一个处理子目录的路由。有关详情,请参阅用户指南
Then you would have to add another route that handles the subdirectory. You can find more information about that in the userguide
这篇关于如何使用模块控制器在Kohana 3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!