t4web / profiler
ZF2 Module. Allow profiling and log slow request
Requires
- php: >=5.5
- t4web/default-service: ^0.1.0
- zendframework/zend-console: ^2.5
- zendframework/zend-db: ^2.5
- zendframework/zend-eventmanager: ~2.5.0
- zendframework/zend-http: ~2.5.0
- zendframework/zend-modulemanager: ~2.5.0
- zendframework/zend-mvc: ~2.5.0
- zendframework/zend-servicemanager: ~2.5.0
- zendframework/zend-view: ~2.5.0
This package is auto-updated.
Last update: 2024-11-26 18:06:48 UTC
README
ZF2 Module. Allow profiling and log slow request
Contents
Introduction
Module for allow profiling page load speed. You can add custom timers for detail analyze page loading workflow.
Installation
Main Setup
By cloning project
Clone this project into your ./vendor/
directory.
With composer
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
Post installation
Enabling it in your application.config.php
file.
<?php return array( 'modules' => array( // ... 'T4web\DefaultService', 'T4web\Profiler', ), // ... );
T4web\Profiler
require T4web\DefaultService
module.
Configuring
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).
Timers
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');