在Kohana 2.3.4中默认加载模块然后加载控制器

时间:2011-07-29 21:36:36

标签: module routes kohana

在Kohana 2.3.4工作时,我需要在访问example.com时加载模块。

routes.php 文件中,您可以指定默认控制器,如:

$config['_default'] = 'welcome'; 

但是指的是主应用程序中的控制器。

默认情况下有没有办法加载模块,然后指定要在该模块中加载的默认控制器?

1 个答案:

答案 0 :(得分:0)

在2.3.4中,您需要指定要在application/config/config.php中加载的模块。加载后,您可以像在标准控制器中一样在路由中使用它们。

假设你的模块中有一个名为foo的控制器和一个名为bar的方法,你的默认路由就是:

$config['_default'] = 'foo/bar';

来自http://docs.kohanaphp.com/general/modules

的配置示例
// Paths are relative to the docroot, but absolute paths are also possible
// Use the MODPATH constant (?)
$config['modules'] = array
(
    MODPATH.'acl',
    MODPATH.'auth',
)

值得注意的是Kohana文件系统是级联的,因此应用程序文件夹中的重复控制器(和其他文件)将覆盖模块控制器,而模块控制器又会覆盖系统控制器。

有关详情,请参阅:http://docs.kohanaphp.com/general/filesystem#cascading