\modules\test\init.php
<?php defined('SYSPATH') or die('No direct script access.');
// Static file serving (CSS, JS, images)
/*
当前url: /index.php/a/1
原始url: /index.php/test/test
*/
/*
Route::set('a', 'a(/<controller>(/<action>))')
->defaults(array(
'controller' => 'test1',
'action' => 'index'
));
*/
Route::set('a', function($uri)
{
if ($uri == 'a/1')
return array(
'controller' => 'test',
'action' => 'index',
);
},
'a/1'
);\modules\test\classes\controller\test.php
<?php defined('SYSPATH') or die('No direct script access.');
/**
* Kohana user guide and api browser.
*
* @package Kohana/Userguide
* @category Controllers
* @author Kohana Team
*/
class Controller_Test extends Controller_Template {
public function before()
{
parent::before();
}
// List all modules that have userguides
public function action_index()
{
echo 'test';
exit;
}
} // End Userguide
本文介绍了一个基于Kohana框架的路由配置示例及控制器实现。通过具体代码展示了如何设置路由并映射到特定的控制器与动作。此外,还包含了一个简单的控制器类,用于演示如何响应请求。
44

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



