Laravel5.1中怎么自定义500错误页面

今天就跟大家聊聊有关Laravel5.1中怎么自定义500错误页面,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

Laravel 5.1中500错误是程序错误,程序错误一定是系统自带的500错误,可以通过以下步骤简单实现自定义500错误页面。

编辑PHP文件app/Exceptions/Handler.php内容如下:

public function render($request, Exception $e)
{
  if ($e instanceof ModelNotFoundException) {
    $e = new NotFoundHttpException($e->getMessage(), $e);
  }
  if($e instanceof \Symfony\Component\Debug\Exception\FatalErrorException 
    && !config('app.debug')) {
    return response()->view('errors.default', [], 500);
  }
  return parent::render($request, $e);
}

然后编辑自定义错误页面对应视图文件errors.default.blade.php。

看完上述内容,你们对Laravel5.1中怎么自定义500错误页面有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。