[Laravel5] Custom Error Pages (and Every 503 Errors)

Laravel 5 is wonderful for handling errors. Creating custom error pages is easy too. You can find one default 500 error page (the one you’ll see when turning your app in maintenance with php artisan down (put it back up with php artisan up) in /ressources/views/errors/500.blade.php. Here is how to create some other ones :

Custom 404 page

  1. Create a new file under :
    /ressources/views/errors/404.blade.php
  2. Customize it. Don’t forget to make it fun ! Here are some cool examples.

Custom 503 page

This one is a bit trickier. By default, Laravel 5 will only load your custom page for HttpException errors.

  1. Open app/Exceptions/Handler.php
  2. Modify the render() function like that :
    public function render($request, Exception $e)
    {
        if (!$this->isHttpException($e)) $e = new \Symfony\Component\HttpKernel\Exception\HttpException(500);
        return parent::render($request, $e);
    }
  3. Then create your new file under /ressources/views/errors/503.blade.php and customize it. Laravel will now redirect all 500 errors to your custom 503 error page.

One thought on “[Laravel5] Custom Error Pages (and Every 503 Errors)

Leave a comment

Design a site like this with WordPress.com
Get started