modules/api/init.php
http://localhost/vlc/vod/index.php/api/a/a
分别对应下面2种路由
Route::set('collect', 'collect(/<controller>(/<action>(/<param>)))' ,array('param'=>'.*'))
->defaults(array(
'controller' => 'collect',
'action' => 'index',
));
Route::set('api', 'api(/<controller>(/<action>(/<param>)))' ,array('param'=>'.*'))
->defaults(array(
'controller' => 'collect',
'action' => 'index',
));其中api/class/controller/a.php
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_A extends Controller {
function action_index()
{
echo("dd");
}
function action_a()
{
echo("aa");
}
}
bootstarp.php中去除默认路由
Kohana::modules(array(
'admin' => MODPATH.'admin',
'api' => MODPATH.'api',
'auth' => MODPATH.'auth', // 用户登录
'cache' => MODPATH.'cache', // Caching with multiple backends
'xcache' => MODPATH.'xcache', // Caching with multiple backends
'database' => MODPATH.'database',
));
/**
* Set the routes. Each route must have a minimum of a name, a URI and a set of
* defaults for the URI.
*/
/*
Route::set('default', '(<controller>(/<action>(/<params>)))' , array('params' => '.*?'))
->defaults(array(
'controller' => 'auth',
'action' => 'index',
));
*/
Cache::$default = 'memcache';//( Kohana::$environment == Kohana::PRODUCTION)?'memcache':'file';
Cookie::$salt = 'VLC-Salt-STRING-Here';
本文介绍了一个使用Kohana框架进行路由配置的例子,并详细展示了如何通过定义不同的路由规则来映射到特定的控制器和动作。同时,文章还介绍了如何在bootstrap文件中加载模块并移除默认路由。
150

被折叠的 条评论
为什么被折叠?



