Kohana 3:如何路由 application/classes/controller 中的子目录
我对 Kohana 很陌生,想知道在 application/classes/controller 目录中组织大量文件的最佳方法是什么。
我当前的结构是:
-application
--classes
---controller
----page
-----test.php
我想从 url 调用页面,而不需要页面或任何其他子目录的名称(可选):
www.website.com/test/
我的控制器类开始:
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Test
*
* @package Test
* @category Page
* @author
*
*/
class Controller_Page_Test extends Controller_Template {
// Default
public function action_index() {
// Template vars
}
}
我需要做什么才能避免它抛出的 404 错误?我假设我需要在 bootstrap.php 中设置一条路由,但我真的不知道该怎么做才能允许页面从子目录中激活。
提前致谢。
I'm quite new to Kohana and was wondering what the best way was of organising a lot of files in the application/classes/controller directory.
My current structure is:
-application
--classes
---controller
----page
-----test.php
And I want to call the page from a url without it needing the page or optionally the name of any other subdirectory:
www.website.com/test/
My controller class starts:
<?php defined('SYSPATH') OR die('No direct access allowed.');
/**
* Test
*
* @package Test
* @category Page
* @author
*
*/
class Controller_Page_Test extends Controller_Template {
// Default
public function action_index() {
// Template vars
}
}
What do I need to do to avoid the 404 error it is throwing? I assume I need to set up a route in bootstrap.php but I don't really get what to do to allow the pages to activate from within subdirectories.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在路由中使用
directory
参数:您可以使用正则表达式作为控制器列表。例如,页面目录中有 Controller_Test 和 Controller_Foo。这是它的路线:
Use
directory
param in Routes:You can use regex for controller list. For example, you have Controller_Test and Controller_Foo in a page directory. Here is a route for it: