Use composer to install:
composer require sp-niemand/yii2-pinba
Add the main component and the log target to the config.
'bootstrap' => [/* ... */ 'pinba' /* ... */],
'components' => [
// ...
'pinba' => [
'class' => \yiiPinba\component\Pinba::className(),
],
// ...
'log' => [
'targets' => [
// ...
[
'class' => \yiiPinba\log\Target::className(),
],
// ...
]
]
// ...
]
The target handles export of the profile logs to Pinba. Use standard Yii2 method for profiling:
\Yii::beginProfile($token, $category);
// ...
\Yii::endProfile($token, $category);
Bootstrapping is needed if you want to automatically time actions run.
Of course, you can use methods from the component directly:
$p = \Yii::$app->get('pinba');
/** @var Pinba $p */
$p->startTimer('timer1');
// ...
$p->stopTimer('timer1');