I've previously had Whoops in 5.1 and 5.0; but since 5.2 the implementation I used earlier no longer works.
I have been unable to find a way to implement Whoops 2.0 to Laravel 5.2 as is.
Any suggestions?
I've previously had Whoops in 5.1 and 5.0; but since 5.2 the implementation I used earlier no longer works.
I have been unable to find a way to implement Whoops 2.0 to Laravel 5.2 as is.
Any suggestions?
Just add this method to your app/Exceptions/Handler.php
file, it overrides the existing method that would generate the Symfony error response. If the app is in config mode, it will return the Whoops response. If you're build some sort of API, you might instead want to use the JsonResponseHandler
over the PrettyPageHandler
which would give you a nice JSON response for exceptions.
/**
* Create a Symfony response for the given exception.
*
* @param \Exception $e
* @return mixed
*/
protected function convertExceptionToResponse(Exception $e)
{
if (config('app.debug')) {
$whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);
return response()->make(
$whoops->handleException($e),
method_exists($e, 'getStatusCode') ? $e->getStatusCode() : 500,
method_exists($e, 'getHeaders') ? $e->getHeaders() : []
);
}
return parent::convertExceptionToResponse($e);
}
Whoops 2.1 was deployed 4 days ago. I just tried with Laravel 5.2 and it worked just fine.
I just followed Matt Stauffer's tutorial.
https://mattstauffer.co/blog/bringing-whoops-back-to-laravel-5