Load a module and then controller by default in Kohana 2.3.4
Working in Kohana 2.3.4, I need to load a module when I go to example.com.
In the routes.php file you can开发者_StackOverflow specify a default controller like:
$config['_default'] = 'welcome';
but that refers to the controllers within the main application.
Is there a way to load a module by default, and then specify the default controller to load within that module?
In 2.3.4 you need to specify which modules you are loading in your application/config/config.php
. Once they're loaded you can use them in your routing just as you would your standard controllers.
Assuming within your module you had a controller named foo and a method named bar your default route would simply be:
$config['_default'] = 'foo/bar';
Example config from 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',
)
It's worth noting that the Kohana filesystem is cascading so duplicate controllers (and other files) in your application folder would override module controllers which in turn override the system controllers.
For more see: http://docs.kohanaphp.com/general/filesystem#cascading
精彩评论