Laravel ships with the ability to put your application into maintenance mode. Here's a quick guide.
From the command line, run the following Artisan command to put your Laravel application into maintenance mode.
php artisan down
Once this completes, anyone visiting your application will be served with a 503
status page.
To bring your application out of maintenance mode, you guessed it! Run the up
command.
php artisan up
Here are some other cool things you're able to do with maintenance mode in Laravel.
If you'd like to instruct visitor's browsers to automatically refresh, you can pass in the refresh
flag and an amount of seconds for the refresh interval.
This is a great feature, since you'll probably want to welcome the user straight back into your application when it comes out of maintenance mode.
php artisan down --refresh=20
The above example will refresh every 20 seconds.
If you personally still need to access your site while it's in maintenance mode, use the secret
flag.
php artisan down --secret="seqG8RL28tcUAIt4uQDyqOeGbIp7K5XE"
Choose any value here, and then access your application's URL like this, using the secret token you gave.
https://example.com/seqG8RL28tcUAIt4uQDyqOeGbIp7K5XE
If you prefer for Laravel to generate a token for you, that's covered too!
php artisan down --with-secret
Like all status pages in Laravel, you can customise the 503 page that's rendered when your application is in maintenance mode.
Create a 503.blade.php
file at resources/views/errors/503.blade.php
and fill it in with the content you'd like the user to see. This page will then be rendered instead of the default.