|
|
I-Framework
I-Framework是基于PHP5面向对象的MVC开发框架
我们的目标是:code meaningfully(更有意义地写代码)
资源
主要特征
- 完全面向对象,类和接口之间结合缜密,易进行扩展
- 容易安装,容易使用
- 功能强大,API精炼而实用
- 代码规范,无令人惊讶的命名和书写方式,和程序员更加亲切
- 从多个Java和RoR开源项目中吸取经验,设计有效而稳定,不必担心每个版本会不兼容
- 吸收并不盲从原则,使我们从成功经验中汲取最精华、最实用的部分
- 强大的MVC,每一个功能都精雕细琢,可调用方法不多不少,恰到好处
- model:既可使用IBATIS的sqlmap,又可以使用类似RoR的ActiveRecord,开发效率奇高
- view:集成PHP代码/JSON/Smarty等多个视图方案,又可使用我们提供的mint模板,体验tapstry的奥妙
- controller:完全掌握action的生命周期,简单而又强大的自定义功能
- 详尽的中文手册和注释,极大降低学习成本
示例
model
/**
* TLog
*
* generated by IF-cli at 2008-01-03 19:40:56
*/
class TLog extends IDarDomain {
public static $MODEL = array(
"tblName" => "tbl_log",
);
/**
* get domain object manager
*
* @return IDarManager
*/
public static function manager() {
return parent::manager(__CLASS__);
}
}view
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>阅读博客</title>
</head>
<body>
<table>
<tr>
<td>标题:</td>
<td>{$log.title}</td>
</tr>
<tr>
<td valign="top">内容</td>
<td>{$log.content|simple_text_format}</td>
</tr>
</table>
</body>
</html>controller http://localhost/index/read/1 对应 appRead方法
<?php
class IndexController extends IApplication {
public function init() {
}
/**
* 读取日志
*
*/
public function appRead() {
$id = $this->in->id;
$this->log = TLog::manager()->find($id);
}
/**
* 添加日志
*
*/
public function appAdd() {
$log = new TLog();
$log->save(array(
"content" => $this->in->content,
"categoryId" => $this->in->category_id,
"submitDate" => date("Y-m-d H:i:s")
));;
echo "add ok";
}
/**
* 删除日志
*
*/
public function appDelete() {
$id = $this->in->id;
$log = TLog::manager()->find($id);
$log->delete();
echo "delete ok";
}
/**
* 修改日志
*
*/
public function appModify() {
$id = $this->in->id;
$this->log = TLog::manager()->find($id);
//如果是post方法
if ($this->in->isPost()) {
$this->log->save(array(
"content" => $this->in->content,
"categoryId" => $this->in->category_id
));
echo "modify ok";
}
}
public function destroy() {
}
}
