Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jove's avatar
Level 7

artisan down, change view

Hello,

How do I change the view that gets rendered when using the artisan down command? I would like to keep my error pages as is, and add a new one for specific this command.

0 likes
7 replies
jove's avatar
Level 7

@m-rk .... " I would like to keep my error pages as is, and add a new one for specific this command."

click's avatar
click
Best Answer
Level 35

Note that by only creating the 503 custom template all of your other error pages are still the same. Only for an error with status code 503 (service unavailable) you will show that custom blade file. And I guess you do not trigger 503 errors manually from your code somewhere.

But if you only want to catch the maintenance mode you could add a condition in your app/Exceptions/Handler.php and render a different view like:

public function render($request, Exception $e)
{
     if ($e instanceof MaintenanceModeException) {
          return \View::make('maintenance');
     }
}
jove's avatar
Level 7

Thanks! Yes the last part is what I'm looking for as it shows a 503 when it crashes hard. So instead of 500, it shows a 503 if the 503 trigger is hit (when it is hit it needs to be looked at before it can be served again, so a 500 does not fit.).

ckalita's avatar

Perhaps, try:


use Illuminate\Foundation\Http\Exceptions\MaintenanceModeException;

class Handler extends ExceptionHandler 
{

    public function render($request, Exception $exception)
    {
        if ($exception instanceof MaintenanceModeException) {
            return response()->view('maintenance-blade-name');
        }

        return parent::render($request, $exception);
    }
}

1 like
messenb's avatar

Expanded data arguments to the view...

    public function render($request, Exception $exception)
    {
        if ($exception instanceof MaintenanceModeException) {
            return response()->view('maintenance', [
                'message' => $exception->getMessage(), 
                'retry' => $exception->retryAfter
            ], 500);
        }
        return parent::render($request, $exception);
    }

With the blade view containing...

<head>
<META HTTP-EQUIV="Refresh" CONTENT="{{ $retry }}">
</head>

and...

<h3>{{ $message }}</h3>
<p>Page will refresh in {{ $retry }} seconds.</p>

Thanks for the help!!!

Please or to participate in this conversation.