如何在 Kohana 3 中使用模块控制器?
对于 Kohana 3 中 / 下的以下应用程序目录结构:
application
- 课程
- 控制器
- controller1.php
模块
- 管理员
- 课程
- 控制器
- controller2.php
网址是:/controller1 和/admin/controller2?
我似乎遗漏了一些东西,因为我不断收到 /admin/controller 的 404 错误。我做错了什么?
确切的错误是:
HTTP_Exception_404 [ 404 ]:在此服务器上找不到请求的 URL admin/borrowers。
而且我没有任何自定义路线设置。此时这是一个非常普通的 K3 安装。
For the following application directory structure under / in Kohana 3:
application
- classes
- controller
- controller1.php
modules
- admin
- classes
- controller
- controller2.php
And the urls be: /controller1 and /admin/controller2?
I seem to be missing something though because I keep getting a 404 error with the /admin/controller. What am I doing incorrectly?
The exact error is:
HTTP_Exception_404 [ 404 ]: The requested URL admin/borrowers was not found on this server.
And I don't have any custom routes setup. This is a very vanilla K3 install at this point.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目录结构好像有点。
使用模块并不自动意味着您有一个子目录。默认路由定义了以下 url 结构:
因此,对于您给出的目录结构,您将得到以下结果:
该操作可以省略,但默认为
index
。如果您想要一个特殊的管理子目录,您首先必须在模块类目录中创建该子目录,如下所示:
然后您必须添加另一个处理该子目录的路由。您可以在用户指南中找到更多相关信息
The directory structure seems to be a little of.
Using a module doesn't automatically means you have a subdirectory. The default route defines the following url structure:
So for the directory structure that you have given, you get the following:
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:
Then you would have to add another route that handles the subdirectory. You can find more information about that in the userguide