ik-oss / mezzio-debugbar
Middleware to insert PHP DebugBar automatically in html responses
Package info
github.com/INTERLIGENT-kommunzieren-GmbH/mezzio-debugbar
pkg:composer/ik-oss/mezzio-debugbar
Requires
- php: ~8.5.0
- laminas/laminas-diactoros: ^3.6
- php-debugbar/php-debugbar: ^3.5
- psr/container: ^1.0 || ^2.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0 || ^2.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
Requires (Dev)
- doctrine/orm: ^3.3
- laminas/laminas-coding-standard: ^3.0
- laminas/laminas-config-aggregator: ^1.14
- mezzio/mezzio: ^3.20
- mezzio/mezzio-router: ^3.17
- php-debugbar/doctrine-bridge: ^3.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5 || ^12.0
Suggests
- doctrine/orm: To use the Doctrine storage
- mezzio/mezzio-router: To use the route collector
- php-debugbar/doctrine-bridge: To use the Doctrine collector
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-22 17:20:21 UTC
README
Middleware to insert PHP DebugBar automatically in html responses for the Mezzio framework.
Maintained by INTERLIGENT kommunizieren GmbH. This is a fork of mostafasy/mezzio-debugbar, which is no longer maintained; that package is in turn a fork of php-middleware/phpdebugbar and middlewares/debugbar.
Requirements
- PHP 8.5
Versions
| Line | Branch | php-debugbar | Doctrine collector |
|---|---|---|---|
| 2.x | master |
^3.5 | via php-debugbar/doctrine-bridge, works with dbal 3 and 4 |
| 1.x | 1.0.x |
^2.2 | uses DBAL\Logging\DebugStack, requires dbal ^3 |
Installation
composer require --dev ik-oss/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\Doctrine\DoctrineCollector; use DebugBar\Storage\FileStorage; use Laminas\ConfigAggregator\ConfigAggregator; use Laminas\Stdlib\ArrayUtils; $aggregator = new ConfigAggregator( [ Ikoss\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 Doctrine 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
DoctrineStorage works with both doctrine/dbal 3 and 4.
Doctrine Collector
This package builds on php-debugbar 3 and collects Doctrine queries through
php-debugbar/doctrine-bridge, which works with doctrine/dbal 3 and 4.
The bridge's DebugBarSQLMiddleware has to be registered on the DBAL configuration before the
connection is created, so it cannot be attached to an existing EntityManager. Register it under
middlewares in your Doctrine config; DoctrineCollectorFactory then picks it up and throws a
RuntimeException if it is missing.
'middlewares' => [ DebugBar\Bridge\Doctrine\DebugBarSQLMiddleware::class, ],
Note
php-debugbar3 removed its bundled bridges, so the Monolog and Symfony mailer collector factories are not available in 2.x; only the Doctrine bridge was republished as a separate package. They still exist in the 1.x line.
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.