我说ThinkPHP CBD

浏览:1790 发布日期:2016/03/22 分类:技术分享 关键字: Tags AOP CBD
C Core-核心
B Behavior-行为
D Driver-驱动

方便讲解,顺序调整一下:

C Core-核心

MVC框架从浏览器打开到页面展示基本流程:

->浏览器输入 http://www.chengbin.name
->Index.php入口
->系统路由 ThinkPHP/Library/Think/Route.class.php
->基础控制器 ThinkPHP/Library/Think/Model.class.php
->系统基础模型 ThinkPHP/Library/Think/Model.class.php
->数据库操作 ThinkPHP/Library/Think/Db.class.php
->系统视图 ThinkPHP/Library/Think/View.class.php
->内置模板引擎 ThinkPHP/Library/Think/Template.class.php
...

以上的各个功能,就是ThinkPHP的核心;

D Driver-驱动

基于功能,为了灵活的扩展,就要有对应的驱动;
电脑重装系统之后,需要装载各种硬件驱动。

以ThinkPHP的DB为例:
//数据库驱动类库目录
ThinkPHP/Library/Think/Db/Driver

根据配置 DB_TYPE,实例化不同的数据库驱动,PDO创建不同的链接dns;
//mysql dns
$dsn = 'mysql:dbname=testdb;host=127.0.0.1';
$dsn = 'mysql:dbname='.$config['database'].';host='.$config['hostname'];

//oracle dns
$dsn = 'oci:dbname=//'.$config['hostname'].($config['hostport']?':'.$config['hostport']:'').'/'.$config['database'];

谈到驱动,最容易联想到的当然是扩展,TP 3.2在架构设计上更加强化了驱动的设计,替代了之前的引擎和模式扩展。

B Behavior-行为
行为定义
1.
行为绑定
1. 绑定标签侦听(AOP切面编程)
行为调用
1. 独立调用
2. 标签调用

行为(Behavior)是ThinkPHP扩展机制中比较关键的一项扩展,行为既可以独立调用,也可以绑定到某个标签Tag中进行侦听(AOP切面编程)。

本篇Tp CBD的骨架,详情请查看文档:
http://document.thinkphp.cn/manual_3_2.html#cbd
最佳答案
评论( 相关
后面还有条评论,点击查看>>