Yaf已提交到PECL Published on 25 June 2011 by laruence 本文地址: https://www.laruence.com/2011/06/26/2083.html 转载请注明出处 是个值得Yaf纪念的日子.. http://pecl.php.net/package/yaf btw: 终于有了at php.net马甲了, 呵呵 Filed in PHP Extension, PHP应用, 随笔 peclphp frameworkYaf Previous Post Debugging a PHP Core — Getting Basic Information Next Post 在Windows下编译Yaf
achun April 6, 2012 Dispatcher request非嵌套问题,发现Yaf对多请求的处理是非嵌套(延期执行)的,虽然forward里面说明了一些,不过如果不是测试还以为只有forward是非嵌套,测试中发现如果一个请求没有完成,强行进行Yaf_Dispatcher::getInstance()->setRequest/dispatch()之类的操作,会发送502错误。 发现只有在dispatchLoopShutdown时才能进行这样的操作。 @鸟哥 在dispatchLoopShutdown中dispatch新的request是安全的么?后续Yaf打算request嵌套么?
achun April 6, 2012 Dispatcher request非嵌套问题,发现Yaf对多请求的处理是非嵌套(延期执行)的,虽然forward里面说明了一些,不过如果不是测试还以为只有forward是非嵌套,测试中发现如果一个请求没有完成,强行进行Yaf_Dispatcher::getInstance()->setRequest/dispatch()之类的操作,会发送502错误。 发现只有在dispatchLoopShutdown时才能进行这样的操作。 @鸟哥 在dispatchLoopShutdown中dispatch新的request是安全的么? 后续Yaf打算做request的嵌套么?
achun April 5, 2012 鸟哥,还是关于forward的问题,在启注册了Yaf_Plugin_Abstract实例后可以hook到preDispatch,postDispatch。发现如果Controller中发生了forward,preDispatch中可以正确的hook到$request和$response,但是postDispatch中的$request变成了forward后的对象,道理上讲的同,不过有几个不方便的地方: 1.preDispatch和postDispatch受forward影响,两个传入参数不一致,还得手工分析 2.forward(Controller,Action)这种模式不能在init中进行 3.forward发生的action不能区分是否skip rander了,即缺少在action中skip rander机制. 测试代码如下 Bootstrap.php中的 public function _initLayout(Yaf_Dispatcher $dispatcher){ $layout = new LayoutPlugin(‘layout.phtml’); Yaf_Registry::set(‘layout’, $layout); $dispatcher->registerPlugin($layout); } 其中,LayoutPlugin采用手册中的默认代码(只有hook方法) index.php class IndexController extends Yaf_Controller_Abstract { public function indexAction() { $this->forward(‘Login’,’login’); } } login.php class LoginController extends Yaf_Controller_Abstract { public function loginAction() { echo __METHOD__,”; } }
achun April 5, 2012 关于forward的问题解决了,因为是照抄http://yaf.laruence.com/manual/yaf.class.controller.forward.html中的例子,而例子里面forward到同一个控制器,才把forward写在了init里面,如果是不同的控制器应该在action里面写,合理,这样就对了,感谢鸟哥,额自言自语了
achun April 5, 2012 抱歉,看来我真是不动php扩展的写法,做了测试发现,我用的是 $this->forward(‘Login’,’login’);也就是forward到了另一个控制器,应该是缺少其他代码造成的,这个如何做呢?
achun April 5, 2012 鸟哥: http://yaf.laruence.com/manual/yaf.class.controller.forward.html 上说 forward( string $controller ,string $action ….) yaf_controller.c 中 PHP_METHOD(yaf_controller, forward) { zval *controller, *module, *action, *args, *parameters; … if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, “z|zzz”…. … 我不懂php扩展的写法,看你其他的代码好像应该是”s|ss”这样的类型吧?
achun April 4, 2012 这是个bug么? Yaf在匹配配置文件的节(section)的时候,不是对名称完全匹配,比如配置里面有 [product] … new Yaf_Application(“conf/app.ini”,’p’)//照样可以被匹配到
Juan Felipe Alvarez Saldarriaga September 2, 2011 Hey!, pretty cool and interesting stuff, I’m a great fan of zend framework, could you provide some speed benchmark? and maybe, just maybe, write the docs in english :P, thanks :).
[…] Yaf已提交到PECL […]
[…] Yaf已提交到PECL […]
[…] Yaf已提交到PECL […]
我下载了php-yaf-doc-2.0.zip,用什么软件编译成chm或者其他格式的电子书?
Dispatcher request非嵌套问题,发现Yaf对多请求的处理是非嵌套(延期执行)的,虽然forward里面说明了一些,不过如果不是测试还以为只有forward是非嵌套,测试中发现如果一个请求没有完成,强行进行Yaf_Dispatcher::getInstance()->setRequest/dispatch()之类的操作,会发送502错误。
发现只有在dispatchLoopShutdown时才能进行这样的操作。
@鸟哥 在dispatchLoopShutdown中dispatch新的request是安全的么?后续Yaf打算request嵌套么?
Dispatcher request非嵌套问题,发现Yaf对多请求的处理是非嵌套(延期执行)的,虽然forward里面说明了一些,不过如果不是测试还以为只有forward是非嵌套,测试中发现如果一个请求没有完成,强行进行Yaf_Dispatcher::getInstance()->setRequest/dispatch()之类的操作,会发送502错误。
发现只有在dispatchLoopShutdown时才能进行这样的操作。
@鸟哥 在dispatchLoopShutdown中dispatch新的request是安全的么?
后续Yaf打算做request的嵌套么?
@achun 这个问题已经修复 🙂
鸟哥,还是关于forward的问题,在启注册了Yaf_Plugin_Abstract实例后可以hook到preDispatch,postDispatch。发现如果Controller中发生了forward,preDispatch中可以正确的hook到$request和$response,但是postDispatch中的$request变成了forward后的对象,道理上讲的同,不过有几个不方便的地方:
1.preDispatch和postDispatch受forward影响,两个传入参数不一致,还得手工分析
2.forward(Controller,Action)这种模式不能在init中进行
3.forward发生的action不能区分是否skip rander了,即缺少在action中skip rander机制.
测试代码如下
Bootstrap.php中的
public function _initLayout(Yaf_Dispatcher $dispatcher){
$layout = new LayoutPlugin(‘layout.phtml’);
Yaf_Registry::set(‘layout’, $layout);
$dispatcher->registerPlugin($layout);
}
其中,LayoutPlugin采用手册中的默认代码(只有hook方法)
index.php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {
$this->forward(‘Login’,’login’);
}
}
login.php
class LoginController extends Yaf_Controller_Abstract {
public function loginAction() {
echo __METHOD__,”;
}
}
关于forward的问题解决了,因为是照抄http://yaf.laruence.com/manual/yaf.class.controller.forward.html中的例子,而例子里面forward到同一个控制器,才把forward写在了init里面,如果是不同的控制器应该在action里面写,合理,这样就对了,感谢鸟哥,额自言自语了
抱歉,看来我真是不动php扩展的写法,做了测试发现,我用的是 $this->forward(‘Login’,’login’);也就是forward到了另一个控制器,应该是缺少其他代码造成的,这个如何做呢?
鸟哥:
http://yaf.laruence.com/manual/yaf.class.controller.forward.html
上说
forward( string $controller ,string $action ….)
yaf_controller.c 中
PHP_METHOD(yaf_controller, forward) {
zval *controller, *module, *action, *args, *parameters;
…
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, “z|zzz”….
…
我不懂php扩展的写法,看你其他的代码好像应该是”s|ss”这样的类型吧?
这是个bug么?
Yaf在匹配配置文件的节(section)的时候,不是对名称完全匹配,比如配置里面有
[product]
…
new Yaf_Application(“conf/app.ini”,’p’)//照样可以被匹配到
Hey!, pretty cool and interesting stuff, I’m a great fan of zend framework, could you provide some speed benchmark? and maybe, just maybe, write the docs in english :P, thanks :).
恭喜啊, 挺不错的东西
鸟哥,感谢你的无私分享
太棒了
Maintainers Xinchen Hui
@kelezyb 在googlecode上已有
能提供一个Win下面的Dll下载么.有利于这个框架的推广啊.感觉这个框架需要做的事情还有很多.
我下载了php-yaf-doc-2.0.zip,用什么软件编译成chm或者其他格式的电子书?????
希望能早日用于生产环境啊
con~
哇牛XX
膜拜大神。Yaf官网地址是?
哗,哥V5啊,是值得纪念,前10的回复会有饭请么,吼吼。
@cfc4n @fcten
三种途径, 1. 开发PHP(PHP Core developer) 2. 开发PECL 3. 翻译PHP手册文档
我也想要一个 at php.net的马甲 >.<
只有在PECL上贡献项目的人才给 at php.net的马甲?
提交BUG不给吗?