bankiru / yii-pinba
该软件包已被弃用且不再维护。未建议替代软件包。
v0.2.0
2016-06-14 10:23 UTC
Requires
- php: ^5.4 | ^7.0
- yiisoft/yii: ~1.1.17
Suggests
- ext-pinba: You should install pinba extension for php
This package is not auto-updated.
Last update: 2022-11-07 16:46:18 UTC
README
一个简单的Yii扩展,封装了Pinba配置和方法。
安装
您需要手动安装php pinba扩展。请参阅 文档。
Composer
"require": {
"bankiru/yii-pinba": "~0.1"
}
Github
Yii框架的Pinba扩展版本可在 Github 上找到。
文档
要启用此扩展,您需要在config.php中的组件列表中添加Pinba,并进行一些简单的配置。
'pinba' => array(
'class' => 'Bankiru\\Yii\\Profiling\\Pinba\\Pinba',
'fixScriptName' => true, // changes script_name in pinba to controller/action or to command args in cli mode. Default true
'scriptName' => null, // default null (if null pinba would use autodetect)
'hostName' => null, // default null (if null pinba would use autodetect)
'serverName' => null, // default null (if null pinba would use autodetect)
'schema' => null, // default null (if null pinba would use autodetect)
'profileEvents' => [], // default empty array
)
此外,您还需要将pinba扩展添加到preload
部分。
提供了两种方法进行性能分析。
- 通过直接调用Timer类
- 使用yii事件
Timer类
Timer类具有静态方法
- start
- stop
- add
- delete
- tagsMerge
- tagsReplace
- dataMerge
- dataReplace
- getInfo
- getAll
- stopAll
这些方法包装了 pinba_* 函数。
Yii事件
扩展始终跟踪CApplication请求(onBeginRequest, onEndRequest)。
可以通过配置添加自定义性能分析。例如
'pinba' => array(
'class' => 'Bankiru\\Yii\\Profiling\\Pinba\\Pinba',
'profileEvents' => [
['my-component-name', 'profiling_action_name', 'onBeginActionEventName', 'onEndActionEventName'],
],
)