1

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?

FooBar
  • 5,752
  • 10
  • 44
  • 93
  • What exactly doesn't work? Can't install via composer, errors or does nothing? – Mark Davidson Jan 21 '16 at 13:51
  • https://github.com/GrahamCampbell/Laravel-Exceptions supporting laravel 5.2 – Amir Bar Jan 21 '16 at 14:03
  • @AmirBar I am using that, but it does a lot of other stuff as well (i.e. exceptionshandler) that I don't want or need. I only want whoops. – FooBar Jan 21 '16 at 15:11
  • @MarkDavidson previously I used this: https://mattstauffer.co/blog/bringing-whoops-back-to-laravel-5 but that does not work for laravel 5.2 – FooBar Jan 21 '16 at 15:12
  • @Mattias so look at the source code and see what you did wrong.. because this package using whoops in laravel 5.2.. – Amir Bar Jan 21 '16 at 16:44

2 Answers2

4

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);
}
Dwight
  • 12,120
  • 6
  • 51
  • 64
1

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

Eduardo Cruz
  • 617
  • 6
  • 18