zend-expressive icon indicating copy to clipboard operation
zend-expressive copied to clipboard

[Question] Doc about debugbar in a programmatic_pipeline context

Open belgattitude opened this issue 7 years ago • 3 comments

Following the doc about debugbars, the php-middleware/php-debug-bar neither bitExpert/prophiler-psr7-middleware didn't work in a 'programmatic_pipelines' context.

What is the recommended way to pipe middleware only for development ?

For now I've ended up adding them in the config/pipeline.php file:

$app->pipe(ErrorHandler::class);

$debug = $app->getContainer()->get('config')['debug'] ?? false;
if ($debug) {
    /* example with phpdebugbar */
    $debugBarFactory = new \PhpMiddleware\PhpDebugBar\PhpDebugBarMiddlewareFactory();
    $middleware = $debugBarFactory();
    $app->pipe($middleware);

    /* example with prophilermiddleware */
    $prophiler  = new \Fabfuel\Prophiler\Profiler();
    $toolbar    = new \Fabfuel\Prophiler\Toolbar($prophiler);
    $middleware = new \bitExpert\Http\Middleware\Psr7\Prophiler\ProphilerMiddleware($toolbar);
    $app->pipe($middleware);
}

$app->pipe(ServerUrlMiddleware::class);
//...

Not sure if it's a good practive. BTW both debugbars looks pretty minimal. Is there any plan to have the ZendDeveloperTools toolbar for expressive ?

Note, for PHP7 and ProphilerMiddleware, you add:

$ composer require --dev fabfuel/prophiler:dev-feature/php7 bitexpert/prophiler-psr7-middleware

belgattitude avatar May 24 '17 13:05 belgattitude

For me looks fine. One think what you can improve it's move building middlewares (with dependencies) to your container.

snapshotpl avatar May 24 '17 14:05 snapshotpl

A good init.

samuel20miglia avatar May 24 '17 18:05 samuel20miglia

This repository has been closed and moved to mezzio/mezzio; a new issue has been opened at https://github.com/mezzio/mezzio/issues/14.

weierophinney avatar Dec 31 '19 20:12 weierophinney