Slim 3 blackholing errors

Looking through the source, it's possible to initialize slim 3 with error display like so:

$app = new \Slim\App(['settings' => ['displayErrorDetails' => true]]);

I'm not sure if it's possible to change this setting after the fact without replacing the errorHandler altogether.


To show full stack trace on default exception handler use what j-v said.

If you want to handle exceptions in Slim yourself then you need to override Slim's default exception handler as it will be used before your "not in Slim" error handler:

$app = new \Slim\App();

$container = $app->getContainer();
$container['errorHandler'] = function(ServerRequestInterface $request, ResponseInterface $response, Exception $exception) {
    //Handle exception here
}

Error handling is rather well documented: Official Docs

$app = new \Slim\App();
$c = $app->getContainer();
$c['errorHandler'] = function ($c) {
    return function ($request, $response, $exception) use ($c) {
         return $c['response']->withStatus(500)
                              ->withHeader('Content-Type', 'text/html')
                              ->write('Something went wrong!');
         };
   };

Tags:

Slim