禅道(zentao)PHP框架介绍

一、zentaoPHP目录结构

            1、顶级目录结构 

            config: 配置文件所在的目录。包含了config.php和my.php  
            db: demo应用所需要的blog.sql framework: 包含了框架的核心文件。 
            js: 包含了js脚本文件。 lib: 包含了常用的类文件。 
            module: 模块目录,每个模块一个目录,存放在module目录下面。 
            theme: 主题文件,包含了css文件和图片文件。 
            .htaccess: apache下面使用的url重写规则文件。 
            favicon.ico: 小图标文件。 
            index.php: 入口程序。

           2、模块的目录结构 

              config.php:  这个模块的配置文件,可以用来存放专门针对这个模块的配置,也可以覆盖全局性的配置。
              lang:        存放各个语言的文件。比如中文存为zh-cn.php,英语存为en.php,繁体存为zh-tw.php。
              control.php  为这个模块对应的控制器类文件。
              model.php    为这个模块对应的业务逻辑类文件。
              view:       存放的各个方法的视图文件。比如index.html.php是index方法的模板文件 

 

二、zentaoPHP框架流程

               

 

 

三、zentaoPHP调用流程源码分析

1、访问入口

            zentaopms/www/index.php

2、引入框架包

include '../framework/router.class.php';
include '../framework/control.class.php';
include '../framework/model.class.php';
include '../framework/helper.class.php';

3、创建应用实例

                                   

 $app = router::createApp('pms', dirname(dirname(__FILE__)), 'router');

  3.1、 初始化应用实例                                       

 public function __construct($appName = 'demo', $appRoot = '')
 { 
 //初始化各种路径
 $this->setPathFix();
 $this->setBasePath();
 $this->setFrameRoot();
 $this->setCoreLibRoot();
 $this->setAppRoot($appName, $appRoot);
 $this->setTmpRoot();
 $this->setCacheRoot();
 $this->setLogRoot();
 $this->setConfigRoot();
 $this->setModuleRoot();
 $this->setWwwRoot();
 $this->setThemeRoot();
 $this->setDataRoot();
 //初始化主配置(zentaopms/config/config.php)
 $this->loadMainConfig();

 $this->loadClass('front', $static = true);
 $this->loadClass('filter', $static = true);
 $this->loadClass('dao', $static = true);
 $this->loadClass('mobile', $static = true);

 $this->setSuperVars();
 $this->setDebug();
 $this->setErrorHandler();
 $this->setTimezone();
 $this->startSession();

 if($this->config->framework->multiSite) $this->setSiteCode() && $this->loadExtraConfig(); 
 // 连接数据库
 if($this->config->framework->autoConnectDB) $this->connectDB();
 if($this->config->framework->multiLanguage) $this->setClientLang();

 $needDetectDevice = zget($this->config->framework->detectDevice, $this->clientLang, false);
 $this->clientDevice = $needDetectDevice ? $this->setClientDevice() : 'desktop';

 if($this->config->framework->multiLanguage) $this->loadLang('common');
 if($this->config->framework->multiTheme) $this->setClientTheme();
 }

4、解析URL请求

    $app->parseRequest();

 /* 框架路由相关设置。Routing settings. */
 $config->requestType = 'PATH_INFO'; // 请求类型:PATH_INFO|PATHINFO2|GET。 The request type: PATH_INFO|PATH_INFO2|GET.
 $config->requestFix = '-'; // PATH_INFO和PATH_INFO2模式的分隔符。 The divider in the url when PATH_INFO|PATH_INFO2.
 $config->moduleVar = 'm'; // 请求类型为GET:模块变量名。 requestType=GET: the module var name.
 $config->methodVar = 'f'; // 请求类型为GET:模块变量名。 requestType=GET: the method var name.
 $config->viewVar = 't'; // 请求类型为GET:视图变量名。 requestType=GET: the view var name.
 $config->sessionVar = 'zentaosid'; // 请求类型为GET:session变量名。 requestType=GET: the session var name.
 $config->views = ',html,json,mhtml,xhtml,'; // 支持的视图类型。 Supported view formats.

5、检查权限

 $common->checkPriv();

6.载入模块

 $app->loadModule();

  6.1、 根据请求url解析出来的模块以及方法找到对应的 control  以及function  进行初始化和调用

/*
 * 创建control类的实例。(相关control _construct类构造方法进行实例初始化)
 * Create a instance of the control.
 **/
$module = new $className();
if(!method_exists($module, $methodName)) $this->triggerError("the module $moduleName has no $methodName method", __FILE__, __LINE__, $exit = true);
$this->control = $module;   

 

/* 调用该方法 Call the method. 调用相关模块control的function 根据返回结果渲染 view 的相关html.php  页面      view 页面和  function 方法名一致*/
call_user_func_array(array($module, $methodName), $this->params);

               

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值