enniosousa/server-error-pages

Laravel server-side error pages

v1.1.0 2022-01-22 18:28 UTC

This package is auto-updated.

Last update: 2024-10-23 00:32:11 UTC


README

Latest Stable Version Total Downloads License

Table of Contents

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

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