kohana 浅析2

然后开始kohana框架的首个实例 即程序员入门必做的hello world

1  从system/config/下复制一份routes.php到 application/config下,这是kohana的默认页配置文件 默认值为

$config['_default'] = 'welcome'; 即controllers/welcome 页面,现在还没有,可以新建一个记住文件名要小写

 

kohana的路由为 http://www.**.com/控制器名/执行方法/ 如果没有方法参数则默认为index

 

建立一个Welcome的类class Welcome_Controller extends Controller   控制器都统一继承Controller父类

 

新建一个index()方法

 public function index(){

 

  echo “hello world”;

}

在浏览器输入http://localhost/welcome   或http://localhost/welcome/index 都可以输出hello world

 

根据MVC,在views层输出看看

public function index(){

 

  $str = “hello world”;

$template = new View('welcome');//实例化视图类在views/welcome

 $template->title = $str;

$template->render(TRUE);

 

}

同时在views目录下建立welcome.php作为视图页面

<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>

<body>

<?PHP
       
    echo $title;
?>

</body>
</html>

即可 输出 hello world ,当然只是简单举例,您也可以用kohana的模板类来实现

转于:http://www.bsdcn.com/ Kohana 中文手册[情人节专版] 本手册为 Kohana Docs v2.2 版本。 本手册制作日期:2009年02月10日 本手册由 icyleaf 制作 --- 参考 常规(General) Kohana 文件系统(Filesystem) - 汉化度 100% 配置(Configuration) - 汉化度 100% URLs - 汉化度 100% 路由(Routing) - 汉化度 99% 加载资源(Loading) - 汉化度 100% 控制器(Controllers) - 汉化度 100% 库(Libraries) - 汉化度 100% 辅助函数(Helpers) - 汉化度 100% 视图(Views) - 汉化度 100% 模型(Models) - 汉化度 100% 事件(Events) - 汉化度 85% 钩子(Hooks) - 汉化度 100% 错误处理(Error Handling) - 汉化度 100% 模块(Modules) - 汉化度 100% 国际化(i18n) - 汉化度 100% 日志(Logging) - 汉化度 100% 核心类(Core) 基准测试类(Benchmark Class) - 汉化度 100% 事件类(Event Class) - 汉化度 100% Kohana 类 - 汉化度 100% Unicode 类 - 汉化度 100% 视图库(View Class) - 汉化度 100% 核心库(Libraries) 缓存库(Cache Library) - 汉化度 100% 日历库(Calendar Library) - 汉化度 95% 验证库(Captcha Library) - 汉化度 99% 数据库库(Database Library) - 汉化度 40% 加密库(Encrypt Library) - 汉化度 100% 图像库(Image Library) - 汉化度 20% 输入库(Input Library) - 汉化度 0% ORM 库 - 汉化度 100% 分页库(Pagination Library) - 汉化度 99% 分析库(Profiler Library) - 汉化度 100% Session 库 - 汉化度 100% URI 库 - 汉化度 99% 校验库(Validation Library) - 汉化度 99% 辅助函数(Helpers) 数组辅助函数 - 汉化度 100% Cookie 辅助函数 - 汉化度 98% 日期辅助函数 - 汉化度 100% 下载辅助函数 - 汉化度 100% Email 辅助函数 - 汉化度 100% Expires Helper - 汉化度 0% Feed 辅助函数 - 汉化度 100% 文件辅助函数 - 汉化度 100% 表单辅助函数 - 汉化度 45% HTML 辅助函数 - 汉化度 100% Inflector Helper - 汉化度 0% 数字辅助函数 - 汉化度 100% 请求辅助函数 - 汉化度 80% 安全性辅助函数 - 汉化度 100% 文本辅助函数 - 汉化度 20% 上传辅助函数 - 汉化度 100% URL 辅助函数 - 汉化度 100% 校验辅助函数 - 汉化度 8% 附加模块(Addons) Archive 扩展 - 汉化度 99% Auth 扩展 - 汉化度 100% Gmaps 扩展 - 汉化度 100% Kodoc 扩展 - 汉化度 100% Payment 扩展 - 汉化度 99%
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值