How to Customize the Artisan Down Page in Laravel.

Customize the Artisan Down Page

In Laravel Artisan has a command php artisan down for the Website Maintainance Mode. and a Custom View will be displayed for all requests into the application. This makes it easy to “disable” your application while it is updating or when you are performing maintenance. A maintenance mode check is included in the default middleware stack for your application. If the application is in maintenance mode, an Symfony\Component\HttpKernel\Exception\HttpException instance will be thrown with a status code of 503.

To enable maintenance mode, execute the down Artisan command:

php artisan down

So after the command, you can see a page like that for all the requests in that Laravel Application.

Default Service Unavailable or Maintainance Page for Laravel Applications

So Now, How to Modify/Customized the Page

Now we are Customize the Page, But why we are customizing the page? Maybe You need to add your Company Logo or Some SPecial Text like We are back in 15 minutes, The server is Down, We are working on it.

The solution is simple. Laravel already has a file or template to customize the page for you. the file is located in

ProjectRootPath/resources/views/errors/503.blade.php
@extends('errors::minimal')
@section('title', __('Service Unavailable'))
@section('code', '503')
@section('message', __('Service Unavailable'))
(The 503.blade file in Laravel 8. If you are using any differnt version of laravel  the file content might be changed)

So Just check the file and change the HTML code of this file whatever you want and the Visitor will be able to see the personal error page with your personal custom error message.

Below there is a simple example

<!doctype html>
<title>Site Maintenance</title>
<style>
    body {
        text-align: center;
        padding: 150px;
    }

    h1 {
        font-size: 50px;
    }

    body {
        font: 20px Helvetica, sans-serif;
        color: #333;
    }

    article {
        display: block;
        text-align: left;
        width: 650px;
        margin: 0 auto;
    }

    a {
        color: #dc8100;
        text-decoration: none;
    }

    a:hover {
        color: #333;
        text-decoration: none;
    }

</style>

<article>
    <h1>We&rsquo;ll be back soon!</h1>
    <div>
        <p>Sorry for the inconvenience but we&rsquo;re performing some maintenance at the moment. If you need to you can
            always <a href="mailto:#">contact us</a>, otherwise we&rsquo;ll be back online shortly!</p>
        <p>&mdash; The TectStuffTeam</p>
    </div>
</article>

The Result

The Customized Service Unavailable or Maintainance Page for our Laravel Applications

In case if the file and the errors folder is not there please create a filder with the errors name and inside errors create 503.blade.php and write the HTML Code which you want.

TheTestStuff Team

You May Also Like

About the Author: Sumanta Kabiraj

Leave a Reply

Your email address will not be published. Required fields are marked *