enniosousa / server-error-pages
Laravel server-side error pages
Installs: 5 572
Dependents: 0
Suggesters: 0
Security: 0
Stars: 16
Watchers: 1
Forks: 6
Open Issues: 1
Type:package
Requires
- laravel/framework: ^5.6.20|5.7.*|5.8.*|6.*|7.*
README
Table of Contents
- Errors Avaliables
- Languages Avaliables
- Installation
- How to Create Custom Error Pages
- Custom Error Messages
Errors Avaliables
- 400 Bad Request
- 401 Unauthorized
- 403 Forbidden
- 404 Not Found
- 405 Method not allowed
- 419 Authentication Timeout
- 429 Too Many Requests
- 500 Internal Server Error
- 502 Bad Gateway
- 503 Service Unavailable
- 504 Gateway Timeout
- Maintenance (used when
php artisan down
)
Languages Avaliables
- English by alexphelps/server-error-pages
- Brazilian Portuguese by Ennio Sousa
- Spanish by Patricia Carmona
Installation
Step 1:Install package via Composer
composer require enniosousa/server-error-pages
Step 2: If you are using Laravel 5, include the service provider within your config/app.php
file.
'providers' => [ EnnioSousa\ServerErrorPages\ServerErrorPagesServiceProvider::class, ];
Step 3: Publish vendor provider
php artisan vendor:publish --provider="EnnioSousa\ServerErrorPages\ServerErrorPagesServiceProvider"
How to Create Custom Error Pages
Step 1: Create new empty file named with HTTP code error at folder resources/views/errors
like specified in Laravel docs.
Step 2: Put the following content in the file you just created.
@include('server-error-pages::template', compact($exception))
Step 3: Add to file resrouces/lang/vendor/en/server-error-pages.php
custom messages following the template:
<?php return [ '000' => [ 'title' => "000 HTTP ERROR", 'description' => "Brief description", 'icon' => "fa fa-cogs green", //icon color options are: green, orange or red 'button' => [ 'name' => "Try This Page Again", 'link_to' => "reload", //options are: reload, home or previous ], 'why' => [ 'title' => "What happened?", 'description' => "Error description" ], 'what_do' => [ 'title' => "What can I do?", 'visitor' => [ 'title' => "If you're a site visitor", 'description' => "Explanation." ], 'owner' => [ 'title' => "If you're the site owner", 'description' => "Explanation" ], ], ], ];
Custom Error Messages
Use abort()
Laravel helper
abort(500, "The server is broken"); abort(403, "You user role does not heave permission to see that.");
Or
php artisan down --message="This application is update process. Wait 10 minutes and try again." --retry=600