ZF2 Module. Allow profiling and log slow request
Module for allow profiling page load speed. You can add custom timers for detail analyze page loading workflow.
Clone this project into your ./vendor/
directory.
Add this project in your composer.json:
"require": {
"t4web/profiler": "~0.1.0"
}
Now tell composer to download T4web\Profiler
by running the command:
$ php composer.phar update
Enabling it in your application.config.php
file.
<?php
return array(
'modules' => array(
// ...
'T4web\DefaultService',
'T4web\Profiler',
),
// ...
);
T4web\Profiler
require T4web\DefaultService
module.
By default profiles not store (using NullAdapter
), for storing page profiles into your DB, you can use DbAdapter
.
Run init script for create profiler
table:
$ php public/index.php profiler init
Change default StorageAdapter
:
'service_manager' => [
'factories' => [
\T4web\Profiler\StorageAdapter\StorageAdapterInterface::class => \T4web\Profiler\StorageAdapter\DbAdapterFactory::class,
],
],
Or, you can implement T4web\Profiler\StorageAdapter\StorageAdapterInterface
for create own profiler storage.
By default profiler calculate basic ZF2 event execution:
{
"route": "1ms",
"dispatch": "12ms",
"render": "0ms",
"finish": "0ms"
}
you can disable this like this:
't4web-profiler' => [
'profiling-timeout' => 500, // in ms
'use-default-listeners' => false,
],
Profiler store request, which execute more than profiling-timeout
option (500ms by default).
You can add any custom timers. Timer - it's name and execution time.
$profiler = $serviceLocator->get(T4web\Profiler\Profiler::class);
$profiler->startTimer('My slow function');
// ...
$profiler->endTimer('My slow function');