2017 © Pedro Peláez
 

library zend-db-profiler

Database profiler for Zend\Db (also plugin for ZendDeveloperTools)

image

webino/zend-db-profiler

Database profiler for Zend\Db (also plugin for ZendDeveloperTools)

  • Thursday, May 24, 2018
  • by Webino
  • Repository
  • 1 Watchers
  • 1 Stars
  • 164 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 54 Forks
  • 0 Open issues
  • 6 Versions
  • 110 % Grown

The README.md

BjyProfiler

Provides Zend\Db adapters with extensions for database query profiling, as well as a profiler similar to ZF1's Zend_Db_Profiler. I ported much of this code from ZF1's Zend_Db., (*1)

Note: this module now works with Zend\Db's built-in profiler., (*2)

Note: PHP >= 5.3.6 is required for stack traces with query profiles., (*3)

Composer/Packagist Users

Please note the name of this project's package has changed to bjyoungblood/bjy-profiler in order to match composer/packagist's new naming conventions. Please update your composer.json to use the new package name., (*4)

Configuration & Usage

Following is a sample database configuration:, (*5)

<?php

$dbParams = array(
    'database'  => 'changeme',
    'username'  => 'changeme',
    'password'  => 'changeme',
    'hostname'  => 'localhost',
    // buffer_results - only for mysqli buffered queries, skip for others
    'options' => array('buffer_results' => true)
);

return array(
    'service_manager' => array(
        'factories' => array(
            'Zend\Db\Adapter\Adapter' => function ($sm) use ($dbParams) {
                $adapter = new BjyProfiler\Db\Adapter\ProfilingAdapter(array(
                    'driver'    => 'pdo',
                    'dsn'       => 'mysql:dbname='.$dbParams['database'].';host='.$dbParams['hostname'],
                    'database'  => $dbParams['database'],
                    'username'  => $dbParams['username'],
                    'password'  => $dbParams['password'],
                    'hostname'  => $dbParams['hostname'],
                ));

                if (php_sapi_name() == 'cli') {
                    $logger = new Zend\Log\Logger();
                    // write queries profiling info to stdout in CLI mode
                    $writer = new Zend\Log\Writer\Stream('php://output');
                    $logger->addWriter($writer, Zend\Log\Logger::DEBUG);
                    $adapter->setProfiler(new BjyProfiler\Db\Profiler\LoggingProfiler($logger));
                } else {
                    $adapter->setProfiler(new BjyProfiler\Db\Profiler\Profiler());
                }
                if (isset($dbParams['options']) && is_array($dbParams['options'])) {
                    $options = $dbParams['options'];
                } else {
                    $options = array();
                }
                $adapter->injectProfilingStatementPrototype($options);
                return $adapter;
            },
        ),
    ),
);

After you've run a couple queries (or before, if you so choose), you can use the service locator to grab the adapter using whatever alias you provide (using Zend\Db\Adapter\Adapter is a good way to simply replace Zend\Db's adapter with my profiling adapter., (*6)

$profiler = $sl->get('Zend\Db\Adapter\Adapter')->getProfiler();
$queryProfiles = $profiler->getQueryProfiles();

The Versions

24/05 2018

dev-master

9999999-dev https://github.com/bjyoungblood/BjyProfiler

Database profiler for Zend\Db (also plugin for ZendDeveloperTools)

  Sources   Download

MIT

The Requires

 

zf2 db profiler zdt

24/05 2018

v1.1.2

1.1.2.0 https://github.com/bjyoungblood/BjyProfiler

Database profiler for Zend\Db (also plugin for ZendDeveloperTools)

  Sources   Download

MIT

The Requires

 

zf2 db profiler zdt

24/05 2018

dev-develop

dev-develop https://github.com/bjyoungblood/BjyProfiler

Database profiler for Zend\Db (also plugin for ZendDeveloperTools)

  Sources   Download

MIT

The Requires

 

zf2 db profiler zdt

22/05 2018

v1.1.1

1.1.1.0 https://github.com/bjyoungblood/BjyProfiler

Database profiler for Zend\Db (also plugin for ZendDeveloperTools)

  Sources   Download

MIT

The Requires

 

zf2 db profiler zdt

11/03 2014

v1.1.0

1.1.0.0 https://github.com/bjyoungblood/BjyProfiler

Database profiler for Zend\Db (also plugin for ZendDeveloperTools)

  Sources   Download

The Requires

 

zf2 db profiler zdt

25/07 2013

v1.0.0

1.0.0.0 https://github.com/bjyoungblood/BjyProfiler

Database profiler for Zend\Db (also plugin for ZendDeveloperTools)

  Sources   Download

The Requires

 

zf2 db profiler zdt