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?
このメソッドをファイルに追加するだけapp/Exceptions/Handler.phpで、Symfony エラー応答を生成する既存のメソッドをオーバーライドします。アプリが構成モードの場合、Whoops 応答が返されます。ある種の API を構築している場合は、代わりに を使用しJsonResponseHandlerてPrettyPageHandler、例外に対して優れた JSON 応答を提供することをお勧めします。
/**
* 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);
}
おっと 2.1 は 4 日前に展開されました。Laravel 5.2 で試してみたところ、問題なく動作しました。
Matt Stauffer のチュートリアルに従ったところです。
https://mattstauffer.co/blog/bringing-whoops-back-to-laravel-5