1.第一次启动会向DB导入必要的数据,并根据设定重写配置文件,以及生成入口的index.php文件
index.php文件最终运行
Tiny::createWebApp($config)->run();
2.类Tiny在文件tiny.php中创建。
public static function createWebApp($config=null) { return self::createApp('WebApp',$config); } public static function createApp($className,$config=null) { //加载项目的时区,默认为中国 date_default_timezone_set('Asia/Shanghai'); //注册脚本执行完毕后调用的动作 register_shutdown_function(array('Tiny','exitScript')); Tiny::initSystemHandler(); return new $className($config); }
3.类WebApp位于文件webapp_class.php中,而run方法,是在其父类App也就是文件application_class.php中
public function run() { //实现对Application的扩展 Tiny::$_iserror = true; $appExtension = ExtensionFactory::getFactory('appExtension'); if($appExtension !== null ) { $appExtension->before(); $this->doRequest(); $appExtension->after(); } else $this->doRequest(); Tiny::$_iserror = false; }
4.接下来看看类WebApp里的方法doRequest
public function doRequest() { Url::urlReWrite(); $this->runController(); } public function runController() { $this->controller = $this->createController(); $this->controller->run(); } public function createController() { $controllerName = Req::args('con')!==null?ucfirst(Req::args('con')):$this->defaultController; $controllerClass = $controllerName.'Controller'; $widgetClass = $controllerName.'Widget'; if(class_exists($controllerClass)) { return new $controllerClass(strtolower($controllerName),$this); } else if(class_exists($widgetClass)) { return new $widgetClass($controllerName,$this); } else if(Tiny::getErrorsController()!==null) { $errorsController = Tiny::getErrorsController(); return $errorsController; } else { return new Controller($controllerName,$this); } }
可以看出webapp是通过con来寻找controller的,如果请求里没有设置con,那么默认使用的是index。寻找的规则大写con值得第一个字母,并且链接字符串“Controller”,比如con=admin,那么寻找的controller类名就是AdminController
5.既然找到了相应的controller了,那么看看调用的run方法是怎样的。run方法存在于controller的父类Controller里,也就是文件controller_class.php里
public function run() { if(Tiny::app()->checkToken('redirect')){ $data = Req::args(); unset($data['con'],$data['act'],$data['tiny_token_redirect']); $this->setDatas($data); } $this->init(); $id = Req::args('act'); if($id ===null) $id = $this->defaultAction; //防止页面的循环调用 if(!$this->module->popRequestStack($this->id.'@'.$id))$this->module->pushRequestStack($this->id.'@'.$id); else if($this->module->popRequestStack($this->id.'@'.$id)) {throw new Exception("Can't repeat redirect to the same position, you action is {$this->id}.",E_USER_ERROR);} $this->action = $this->createAction($id); //所有Controller处理的扩展处理 $contExtensions = ExtensionFactory::getFactory('controllerExtension'); if($contExtensions !== null ) { $contExtensions->before($this); if(!is_null($this->action))$this->action->run(); $contExtensions->after($this); } else if(!is_null($this->action))$this->action->run(); }
根据参数act的值来查找其对应的action,默认是index。这里为了防止循环调用,会把以字符串“con@act”的形式把调用过的action存起来,然后检查是否调用过。
接下来看看action是如何创建的
public function createAction($id) { if($id ==='') $actionId = $this->defaultAction; //统一拦截权限控制 if($this->checkRight($id) == false) { $this->noRight(); }else{ //如果控制器直接定义了方式 if(method_exists($this,$id)) { return new InlineAction($this,$id); } else { return new Action($this, $id); } } }
如果这个controller类里有以action命名的方法,那么就创建InlineAction类,如果没有,就创建Action类
linlineAction类的run方法很简单,就是直接执行那个方法
class InlineAction extends BaseAction { //Action运行入口 public function run() { $controller=$this->getController(); $methodName=$this->getId(); $controller->$methodName(); } }
如果以act值命名的方法不存在的话, 那么再来看看Action类,它的run方法比较长,那么我们就来看看关键的几个地方。
$methodName = preg_split("/_(?=(save|del|edit)$)/i",$this->getId()); $operator = array('save'=>'save','del'=>'delete','edit'=>'find'); if($controller->getAutoActionRight() && array_key_exists($op,$operator)) { $model = new Model($modelName); $data=$model->data(Req::args())->$operator[$op](); }
当方法名也就是act的值是以xxxx_save,xxxx_del,xxxx_edit命名时,且登录者有自动action权限时(权限的判断可参考controller_class类的$autoActionRight值设定),可以自动对表(xxxx)进行插入,删除,更新操作。
如果方法名并没有这个规则,或者没有权限的话。那么
else { $action = new ViewAction($controller, $this->getId()); $action->run(); //exit; }
继续跟踪一下类ViewAction可以看到其实就是直接输出view目录下,以con的值为子目录名,以act的值为文件名的php文件。
相关推荐
2、根据测试点设计详细的测试步骤包括,主题,设计者,类型,测试名称,状态,描述Comments,优先级,步骤名,描述,预期结果等 3、将设计好的测试矩阵,测试用
tinyshop开发指南。简单的从框架设计、应用开发、主题开发、模版标签,路由规则
1.2 系统概述TinyShop一款电子商务系统(网店系统),适合企业及个人快速构建个性化网上商店 1.2.1 项目名称项目名称: TinyShop网上商城项目
TinyShop二次开发说明文档。TinyShop一款电子商务系统(网店系统),适合企业及个人快速构建个性化网上商店。系统是基于Tiny(自主研发)框架开发的。
Tinyshop网上商城系统安装手册1
Xammp
解压密码www.xinxi18.com TinyShop是新型的电子商务平台系统,适合企业及个人快速构建个性化网上商店。系统是基于Tiny框架开发的,使系统更加的安全、快捷、稳定、高性能。
TinyShop电子商务系统支付插件简介 TinyShop电子商务系统支付插件是以tinyshop1.7版本为基础进行开发的网站支付宝插件系统。 TinyShop电子商务系统支付插件安装方法: 一、做好网站文件及数据库的备份,以防出错...
TinyShop PHP开源网站系统是一款新型的电子商务网店系统,开源源码构建,内核基于Tiny框架,TinyShop使每个...TinyShop后台功能模块总览:商品中心、订单中心、客户中心、营销推广、统计报表、内容管理、系统设置等。
1.2 业务范围本系统主要包括:新用户注册、用户登录、商品搜素、查看商品信息、为商品添加评论、商品加入购物车、删除购物车商品、商品订单支付 1.3 读者对象本文
TinyShop个性化网上商店系统,基于Tiny框架开发,运行于PHP环境,采取MVC的架构方式,特有Widget机制,使开发插件更加的方便,TinyShop商城参考了国内外众多商城的设计,使每个商品都可设计出自己的特有的规格,使...
TinyShop电子商务系统支付插件是以tinyshop1.7版本为基础进行开发的网站支付宝插件系统。安装方法:一、做好网站文件及数据库的备份,以防出错。二、把这三个文件覆盖到 网站根目/protected/classes/payments/ 下面...
2项目背景介绍TinyShop一款电子商务系统(网店系统),适合企业及个人快速构建个性化网上商店。支持基于IE、Firefox等浏览器。该网站主要是提供用户在网
商城参考了国内外众多商城的设计,提取那些更适合现在发展的元素,去除老旧没有的部分,使系统在设计都就做到的简单易用,系统特别产品高效发布,强大的规格设计,使每个商品都可设计出自己的特有的规格,专门的规格...
TinyShop一款电子商务系统(网店系统),适合企业及个人快速构建个性化网上商店。系统是基于Tiny(自主研发)框架开发的,使系统更加的安全、快捷、稳定、高性能。
TinyShop一款电子商务系统(网店系统),适合企业及个人快速构建个性化网上商店。系统是基于Tiny(自主研发)框架开发的,使系统更加的安全、快捷、稳定、高性能。
送测要求销售助手开发人员提交的测试按以下要求进行:步骤动作负责人相关文档或记录要求1打包、编译开发人员无确认可测试2审核并提交测试测试人员经审核的上一级测试报告
TinyShop一款电子商务系统(网店系统),适合企业及个人快速构建个性化网上商店。系统是基于Tiny(自主研发)框架开发的,使系统更加的安全、快捷、稳定、高性能。
TinyShop电子商务系统.zip
播放清单 项目设置 npm install 编译和热重装以进行开发 npm run serve 编译并最小化生产 npm run build 整理和修复文件 npm run lint 自定义配置 请参阅。 TinyShop