我以前在5.1和5.0中有过呼呼;但从5.2开始,我之前使用的实现不再有效。
我一直无法找到一种方法来实现Laravel 5.2的呼呼2.0。
有什么建议吗?
发布于 2016-01-22 07:50:02
只需将此方法添加到您的app/Exceptions/Handler.php文件中,它将覆盖生成Symfony错误响应的现有方法。如果应用程序处于配置模式,它将返回呼呼响应。如果您正在构建某种应用程序接口,那么您可能希望在PrettyPageHandler上使用JsonResponseHandler,这将为您提供一个很好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);
}发布于 2016-03-18 04:32:57
哇2.1是在4天前部署的。我刚刚尝试了Laravel 5.2,它工作得很好。
我只是遵循了Matt Stauffer的教程。
https://mattstauffer.co/blog/bringing-whoops-back-to-laravel-5
https://stackoverflow.com/questions/34921083
复制相似问题