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?
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.
To perform maintenance mode on Laravel, run the down Artisan command.
Artisan::call('down'); To bring the application remove the file or call the up command, as shown above.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With