Laravel 5.1 中如何自定义 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


点赞 取消点赞 收藏 取消收藏

<< 上一篇: 将 MySQL 中已存在的数据表转化为 Laravel 迁移文件

>> 下一篇: 不基于任何模型使用 Laravel 5.1 的授权功能