Whoops for Laravel 5

Method 01

Instantiating Whoops in the render method doesn’t work quite like it did in 5.1. The render method in Laravel’s exception handler actually handles a number of default exceptions for you, like the validation HTTP exception or the ModelNotFoundException. In these instances you might actually want the page to render with the validation errors or the 404, so it’s better to let them be handled that way. Instead, you can override the method in app/Exceptions/Handler.php that generates the Symfony exception response and instead use Whoops.

* 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(
method_exists($e, ‘getStatusCode’) ? $e->getStatusCode() : 500,
method_exists($e, ‘getHeaders’) ? $e->getHeaders() : []

return parent::convertExceptionToResponse($e);


Method 02

composer require filp/whoops

then in app/Exceptions/Handler.php

public function render($request, Exception $e)
// return parent::render($request, $e);
if (config(‘app.debug’) && ! $request->ajax()) {
$whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler);

return $whoops->handleException($e);

return parent::render($request, $e);



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s