mscharl / pretty-error-page
Nice error pages for Laravel 4.2
Requires
- php: >=5.4.0
- illuminate/support: 4.2.*
This package is not auto-updated.
Last update: 2020-01-22 01:58:49 UTC
README
This package provides nice looking, customizable and localizable error pages, with two predefined views for Laravel.
By default pretty error pages are displayed when debug-mode is disabled and the requests does not expects a JSON-response.
Install
This version (1.*) is compatible with Laravel 4.2
composer require mscharl/pretty-error-page:1.*
Add the service provider 'Mscharl\PrettyErrorPage\PrettyErrorPageServiceProvider'
to your app.php
providers array.
Publish public assets
php artisan asset:publish
Customize
You can easily customize the output of this package by following those steps
Configuration
php artisan config:publish mscharl/pretty-error-page
Config values
- always_pretty
bool|null
null
(default) use pretty error page only when debug mode is offtrue
always show pretty error page (except when expecting a JSON-Response)false
never show pretty error page
Translations
Unfortunately publishing lang-files like config- or view-files is not supported by default. But you still can customize the translation since they are the easiest way to customize a general or specific error output. You do not need to edit anything inside the views. Translations are automatically loaded by the thrown http-status-code.
Translation will be looked up by the package in the following order:
pretty-error-page-customized::404.title > pretty-error-page-customized::general.title > pretty-error-page::404.title > pretty-error-page::general.title
Customize specific error code translations
Create a [errorcode].php
file into app/lang/packages/mscharl/pretty-error-page/[langcode]
.
Customize fallback translations
Create a generic.php
file into app/lang/packages/mscharl/pretty-error-page/[langcode]
.
Required translation keys
<?php return [ 'title' => 'Whoops!', 'header_title' => 'Whoops! Something went wrong.', 'description' => 'Something went wrong.', 'submit_bug' => 'If this problem presits, pleace contact our <a href=":link">Support-Team</a>', ];
Views
php artisan asset:publish mscharl/pretty-error-page
You can either override the predefined templates or just add custom error pages for specific error codes.
layouts
mail.blade.php
: This file is used to render the email body that can be sent by the user getting the error to inform you about the incidence.default.blade.php
: This file is used to define a general layout for the error pages. Every error template should extend this layout for simplicity.
-
shared variables:
$message
: The error message$exception
: The full PHP-Exception
-
partials/log.blade.php
: This file defines the log that can be sent to you by mail. The log is automatically included into every mail by the mail layout. -
[langcode].blade.php
: The E-Mail body for the language with this language code
pages
The error pages. There is a simple naming system.
If an error page is displayed the specific error code is used as the primary filename e.g. 503
. If this is not found 5xx
will be used. If this is still not found any
will be used as fallback.
404.blade.php
: The predefined 404-Error-Page503.blade.php
: The predefined 503-Error-Pageany.blade.php
: The fallback error page if no specific page is found