kohana路由

本文介绍了一个使用Kohana框架进行路由配置的例子,并详细展示了如何通过定义不同的路由规则来映射到特定的控制器和动作。同时,文章还介绍了如何在bootstrap文件中加载模块并移除默认路由。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

modules/api/init.php


http://localhost/vlc/vod/index.php/collect/a/a
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';





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值