Jayson Minard的blueprint for php applications中提到了消息入口Bootstrapping的多种实现方式。在zf中1.7中,一个index.php文件的入口已经更近一步的简化。
当然也是支持传统的写法的。而在FrontController中,接受的url的进行dispatche,其路由情况如下:
// Begin dispatch
try {
/**
* Route request to controller/action, if a router is provided
*/
/**
* Notify plugins of router startup
*/
$this->_plugins->routeStartup($this->_request);
$router->route($this->_request);
/**
* Notify plugins of router completion
*/
$this->_plugins->routeShutdown($this->_request);
/**
* Notify plugins of dispatch loop startup
*/
$this->_plugins->dispatchLoopStartup($this->_request);
/**
* Attempt to dispatch the controller/action. If the $this->_request
* indicates that it needs to be dispatched, move to the next
* action in the request.
*/
do {
$this->_request->setDispatched(true);
/**
* Notify plugins of dispatch startup
*/
$this->_plugins->preDispatch($this->_request);
/**
* Skip requested action if preDispatch() has reset it
*/
if (!$this->_request->isDispatched()) {
continue;
}
/**
* Dispatch request
*/
try {
$dispatcher->dispatch($this->_request, $this->_response);
} catch (Exception $e) {
if ($this->throwExceptions()) {
throw $e;
}
$this->_response->setException($e);
}
/**
* Notify plugins of dispatch completion
*/
$this->_plugins->postDispatch($this->_request);
} while (!$this->_request->isDispatched());
重点代码:
$router->route($this->_request);
$router为一个Zend_Controller_Router_Rewrite对象,_request为一个Zend_Controller_Request_Http对象,其封装了一个http请求,其中有一个参数_requestUri,该参数为一个请求的uri,其形式上可能为/index/index?parameter=value。该uri形式上有两段,其中一段为pathInfo,一部分为queryInfo。
在Zend_Controller_Router_Rewrite有代码如下:
// TODO: Should be an interface method. Hack for 1.0 BC
if (!method_exists($route, 'getVersion') || $route->getVersion() == 1) {
$match = $request->getPathInfo();
} else {
$match = $request;
}
if ($params = $route->match($match)) {
$this->_setRequestParams($request, $params);
$this->_currentRoute = $name;
break;
}
其中$match为PathInfo,即/index/index。$router为一个Zend_Controller_Router_Route_Module对象,对象中函数match返回一个数组
["controller"]=>
string(5) "index"
["action"]=>
string(5) "index"
["module"]=>
string(7) "default"。match函数部分代码如下:
$this->_setRequestKeys();
$values = array();
$params = array();
if (!$partial) {
$path = trim($path, self::URI_DELIMITER);
} else {
$matchedPath = $path;
}
if ($path != '') {
$path = explode(self::URI_DELIMITER, $path);
if ($this->_dispatcher && $this->_dispatcher->isValidModule($path[0])) {
$values[$this->_moduleKey] = array_shift($path);
$this->_moduleValid = true;
}
其中:
self::URI_DELIMITER
是一个const,定义如下:
const URI_DELIMITER = '/';
于是返回如上所示数组。Zend_Controller_Router_Rewrite对象中使用了函数_setRequestParams设置module、controlloer和action的名称。
于是在类Zend_Controller_Front中的_request中已经具备了router的信息条件。
未完待续。
分享到:
相关推荐
NULL 博文链接:https://xiaoyangok.iteye.com/blog/1849451
其中包括zf框架的配置资料和中文学习手册。对于初学者有一定帮助。
V-BLAST系统的ZF检测ZF检测:线性检测包括ZF(迫零)和MMSE(最小均方误差),检测一般有三步:1、根据准则得到线性加权向量。2、利用线性加权向量得到判决统计量。3、对判决统计量进行判决。
基于ZF预编码性能 画出不同准则下误码率和信噪比的曲线
3.用处:用于ZF,MMSE,ZF-DFE,MMSE-DFE四种均衡算法编程学习 4.指向人群:本硕博等教研学习使用 5.运行注意事项: 使用matlab2021a或者更高版本测试,运行里面的Runme_.m文件,不要直接运行子函数文件。运行时注意...
zf model zf 模型,一共两个,第二个.
2*2MIMO瑞利信道下的信道仿真,检测方式包括 ZF
该文章讲述了ZF和MMSE 预编码技术的基本原理,并最后进行了仿真比较
采埃孚ZF变速箱培训学习教案.pptx
Blessed by a friend.
Ahy_zf.shx 是CAD图纸设计与查看特殊字体,可以解决无法查看部分CAD文字缺失的问题。希望能帮到大家。
3.用处:用于ZF均衡器和ML均衡器算法编程学习 4.指向人群:本硕博等教研学习使用 5.运行注意事项: 使用matlab2021a或者更高版本测试,运行里面的Runme_.m文件,不要直接运行子函数文件。运行时注意matlab左侧的...
mimo检测算法zf.zf-sic,mmse,mmse-sic性能曲线的matlab仿真,实测可用
由于ZF2的特殊结构,提供的验证码组件需要设置才能用。 终于找到这个,分享一下共同学习
实现了zf和MMSE预编码下的信道容量,对朋友们的学习会有一定的帮助
该故障表用于ZF变速箱的维护检修检测。中文手册用于吊车,英文手册用于油田工业设备。
代码实现ZF迫零预编码功能。在移动通信系统中,由于多用户干扰,造成接收端信号受到干扰,可以通过在站端进行预编码消除。
基本的线性预编码,包含MRT,ZF,RZF,MF预编码
采埃孚ZF变速箱培训PPT学习教案.pptx
zf2 框架下的模版实例,网上教程改写,帮助新手学习