Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel display a custom message in Maintenance Mode

I'm checking out Laravel docs for Maintenance Mode:

https://laravel.com/docs/5.3/configuration#maintenance-mode

When you execute the command php artisan down, it will put the application under maintenance mode, and return the 503.blade.php view.

Works good, but there is an option I can't really make work.. when I do:

php artisan down --message='Upgrading Database' --retry=60

I want to display the message in the view, I tried accessing the obvious choice with {{ $message }} without success, returns undefined variable.

My question is: how to access it?

like image 717
sigmaxf Avatar asked Sep 10 '16 02:09

sigmaxf


People also ask

How do you do maintenance mode in Laravel?

Laravel 8 introduced secret in maintenance mode, in which you can bypass the maintenance mode by providing a secret, then your Artisan::call would work. You could add your routes to the $except var in CheckForMaintenanceMode middleware to bypass the check. Then your site/live route would work just fine.

Which command we can use to Laravel site in maintenance mode?

To perform maintenance mode on Laravel, run the down Artisan command.

What Artisan command bring the application out of maintenance mode?

Artisan::call('down'); To bring the application remove the file or call the up command, as shown above.

How do I turn off maintenance mode in Laravel?

php artisan down creates the file storage/framework/down . When this file exists, laravel assumes maintainence mode. Delete it, or run php artisan up to end maintainence mode.


1 Answers

Actually you don't need that "json_decode" stuff, as all the "error" views (including 503.blade.php) have $exception variable.

So you may just use {{ $exception->getMessage() }} in your view and you will get the exact value that you have passed to artisan down --message command.

like image 169
Antony Sklyar Avatar answered Oct 02 '22 05:10

Antony Sklyar