Skip to content

php-middleware/phpdebugbar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

phpdebugbar middleware Build Status

PHP Debug bar PSR-15 middleware with PSR-7. Also supports PSR-11

This middleware provide framework-agnostic possibility to attach PHP Debug Bar to your response (html on non-html!).

Installation

composer require php-middleware/php-debug-bar

To build this middleware you need to injecting inside PhpDebugBarMiddleware instance DebugBar\JavascriptRenderer (you can get it from DebugBar\StandardDebugBar) and add middleware to your middleware runner. Or use default factory.

$debugbar = new DebugBar\StandardDebugBar();
$debugbarRenderer = $debugbar->getJavascriptRenderer('/phpdebugbar');
$middleware = new PhpMiddleware\PhpDebugBar\PhpDebugBarMiddleware($debugbarRenderer);

// OR

$factory = new PhpMiddleware\PhpDebugBar\PhpDebugBarMiddlewareFactory();
$middleware = $factory();

$app = new MiddlewareRunner();
$app->add($middleware);
$app->run($request, $response);

You don't need to copy any static assets from phpdebugbar vendor!

How to install on Zend Expressive?

Follow Zend Expressive documentation.

How to install on Slim 3?

Add existing factory to container:

$container['debugbar_middleware'] = new PhpMiddleware\PhpDebugBar\PhpDebugBarMiddlewareFactory();

and add middleware from container to app:

$app->add($app->getContainer()->get('debugbar_middleware'));

How to configure using existing factories?

Put array with configuration into config service in your container:

return [
    'phpmiddleware' => [
        'phpdebugbar' => [
            'javascript_renderer' => [
                'base_url' => '/phpdebugbar',
            ],
            'collectors' => [
                DebugBar\DataCollector\ConfigCollector::class, // Service names of collectors
            ],
            'storage' => null, // Service name of storage
        ],
    ],
];

It's just works with any modern php framework!

Middleware tested on:

And any other modern framework supported middlewares and PSR-7.

About

PSR-15 middleware for PHP Debug bar

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages