odan / slim4-skeleton

A Slim 4 Skeleton
https://odan.github.io/slim4-skeleton/
MIT License
439 stars 80 forks source link

How to use the /src/Handler/DefaultErrorHandler.php #37

Closed notflip closed 3 years ago

notflip commented 3 years ago

I'm looking into ways of outputting more information when a 404 happens, I'm using the following code at the moment

    $app->addBodyParsingMiddleware();
    $app->addRoutingMiddleware();

    // Error Middleware
    $loggerFactory = $app->getContainer()->get(\App\Factory\LoggerFactory::class);
    $logger = $loggerFactory->addFileHandler('error.log')->createInstance('error');

    $app->addErrorMiddleware(true, true, true, $logger);

So I'm wondering, the file in this repository, src/Handler/DefaultErrorHandler.php, how can I make sure that this one is used instead of the default in Slim? Thank you!

Edit Closed, this is clearly defined in the docs but for some reason I missed it

odan commented 3 years ago

You can also find more examples here: https://odan.github.io/2020/05/27/slim4-error-handling.html