Skip to content

Latest commit

 

History

History
160 lines (127 loc) · 5.46 KB

README.md

File metadata and controls

160 lines (127 loc) · 5.46 KB

-forked from : https://github.com/middlewares/debugbar

-forked from : https://github.com/php-middleware/phpdebugbar

mezzio/debugbar

Software License Testing Total Downloads

Middleware to insert PHP DebugBar automatically in html responses for Mezzio Framwork.

Requirements

  • PHP >= 7.4

Installation

composer require --dev mostafasy/mezzio-debugbar 

Example

This package supplies a config provider, which could be added to your config/config.php when using laminas-config-aggregator or mezzio-config-manager. However, because it should only be enabled in development, we recommend creating a "local" configuration file (e.g., config/autoload/php-debugbar.local.php) when you need to enable it, with the following contents:

use DebugBar\Bridge\DoctrineCollector;
use DebugBar\Storage\FileStorage;
use Laminas\ConfigAggregator\ConfigAggregator;
use Laminas\Stdlib\ArrayUtils;

$aggregator = new ConfigAggregator(
    [
        Mezzio\DebugBar\ConfigProvider::class,
    ]
);
return ArrayUtils::merge(
    $aggregator->getMergedConfig(),
    [
// here you can overload the default Values .as example add doctrine collector or fileStorage
        'debugbar'     => [
            'disable'    => false,
            'captureAjax' => true,
            'collectors' => [
                DoctrineCollector::class,
            ],
            'storage'    => FileStorage::class,
            'storage_dir' =>'path/to-your-storage-dir'
        ],
    ]
);

Disable config

Sometimes you want to have control when enable or disable PHP Debug Bar:

  • We allow you to disable attaching phpdebugbar using X-Disable-Debug-Bar: true header, cookie or request attribute.
  • or you can configure in config:
'disable'=>true

captureAjax conifg

Use this option to capture ajax requests and send the data in the headers. More info about AJAX and Stacked data. By default it's disabled.

inline

Set true to dump the js/css code inline in the html. This fixes (or mitigate) some issues related with loading the debugbar assets.

renderOptions

Use this option to pass render options to the debugbar as an array. A list of available options can be found at https://github.com/maximebf/php-debugbar/blob/master/src/DebugBar/JavascriptRenderer.php#L132

An example usage would be to pass a new location for the base_url so that you can rewrite the location of the files needed to render the debug bar. This can be used with symlinks, .htaccess or routes to the files to ensure the debugbar files are accessible.

File Storage

It will collect data as json files under the specified directory (which has to be writable).you can configure as :

'storage'    => FileStorage::class,
'storage_dir' =>'path/to-your-storage-dir'

pdo Storage

It will collect data and saved to database you can configure as :

'storage'    => PdoStorage::class,
'pdo' =>[
  'dsn'=>'mysql:dbname=testdb;host=127.0.0.1';',
  'username'=>'dbuser',
  'password'=>'dbpass',
],

please note you have to execute sql schema pdo-sql-Schema

Doctrine Storage

It will collect data and saved to database by using Doctine you can configure as :

'storage'    => DoctrineStorage::class,
  'doctrine_storage'=>[
    // it will save queries into extra table for analysis purpose.by default it is false.
    'save_sql_queries_to_extra_table' => true,
    ],

you have to execute sql schema: doctrine-sql-Schema


Route Colloctor

It will collect the Route Informations. we can add the collectors to config as the following:

  'collectors' => [
                RouteCollector::class,
            ],

Example of Route config:

 'routes' => [
        [
            'path' => '/path/to/match',
            'middleware' => 'Middleware service or pipeline',
            'allowed_methods' => ['GET', 'POST', 'PATCH'],
            'name' => 'route.name',
            'options' => [
                'stuff' => 'to',
                'pass'  => 'to',
                'the'   => 'underlying router',
            ],
        ],
        'another.route.name' => [
            'path' => '/another/path/to/match',
            'middleware' => 'Middleware service or pipeline',
            'allowed_methods' => ['GET', 'POST'],
            'options' => [
                'more'    => 'router',
                'options' => 'here',
            ],
        ],
    ],


Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details.

The MIT License (MIT). Please see LICENSE for more information.