日志未经声明,均为AlloVince原创。本作品采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可。
Zend1.0时代有非常棒的工具ZFDebug,但在ZF2下显然还没有什么太好的方法。
这里推荐老办法,用Xdebug + 分析工具,勉强可以分析ZF2执行效率和引用文件。
在php.ini内如下设置
zend_extension = "D:\xampp\php\ext\php_xdebug.dll" xdebug.collect_includes = 1 xdebug.profiler_enable = 0 xdebug.profiler_enable_trigger = 1 xdebug.profiler_output_dir = "D:\xampp\tmp" xdebug.profiler_output_name = "cachegrind.out.%u.log"
其中xdebug扩展的位置以及profiler的输出路径都需要根据实际情况调整。
配置完毕后重启Apache,在zf2项目URL中加入XDEBUG_PROFILE即可开启Xdebug Log输出,而平时则不会产生log。
http://localhost/?XDEBUG_PROFILE
输出log在windows下用WinCacheGrind,在Linux下用KCachegrind打开即可。也可以用PHP实现的项目Webgrind。Webgrind的作者也是ZFDebug的作者。
Donate:Buy me a coffee| 文章有帮助,可以请我喝杯咖啡