Laravel5.1自定义500错误页面示例

Olga ·
更新时间:2024-09-21
· 653 次阅读

本文实例讲述了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。

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《smarty模板入门基础教程》、《php日期与时间用法总结》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

您可能感兴趣的文章:Laravel4中的Validator验证扩展用法详解如何优雅的使用 laravel 的 validator验证方法Laravel Validator 实现两个或多个字段联合索引唯一Laravel实现自定义错误输出内容的方法PHP使Laravel为JSON REST API返回自定义错误的问题Laravel5框架自定义错误页面配置操作示例Laravel Validator自定义错误返回提示消息并在前端展示



自定义 laravel 示例 500错误

需要 登录 后方可回复, 如果你还没有账号请 注册新账号