标签:
怎样在laravel5中安装“漂亮的whoops样式的错误处理器”,下面告诉你如何的在laravel5中使用它
1、首先,composer require file/whoops:~1.0.
2、然后打开app/Exception/Handler.php,在render()方法中添加一个whoops样式的处理情况,就像下面这样:
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
if ($this->isHttpException($e))
{
return $this->renderHttpException($e);
}
if (config(‘app.debug‘))
{
return $this->renderExceptionWithWhoops($e);
}
return parent::render($request, $e);
}
/**
* Render an exception using Whoops.
*
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
protected function renderExceptionWithWhoops(Exception $e)
{
$whoops = new \Whoops\Run;
$whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
return new \Illuminate\Http\Response(
$whoops->handleException($e),
$e->getStatusCode(),
$e->getHeaders()
);
}
3、就这么简单
原文的地址:https://mattstauffer.co/blog/bringing-whoops-back-to-laravel-5
标签:
原文地址:http://www.cnblogs.com/wendyhome/p/5147848.html