zeuxisoo / php-slim-whoops

PHP whoops error on slim framework
132 stars 10 forks source link

php-slim-whoops ignores middlewares added before #22

Closed qqux closed 6 years ago

qqux commented 6 years ago

Using the "better DI" way. Keep in mind that in Slim, middlewares are executed the reverse order they're added. Therefore,

In this case, You can place this line anywhere no position required

is not really true in the current state, as the middlewares added before Whoops are not executed. This may result in unintended consequences.

<?php

require('vendor/autoload.php');

$app = new \Slim\App();

$app->add(function ($req, $res, $next) {
    die('Should display this');
});

$app->add(new \Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware($app));

$app->get('/', function ($req, $res) {
    die('Should not display this');
});

$app->run();
zeuxisoo commented 6 years ago

Thank you for your report. You may be right. I will find time to fix this problem