tanedaa / laravel-dynamic-maintenance
A Laravel package to enable maintenance mode for specific named routes
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Language:Blade
Requires
- php: ^8.1
- illuminate/support: ^10.0|^11.0
README
A simple package to allow enabling maintenance mode for specific named routes.
Installation
Require this package with composer. Works for Laravel 10 and above. Not tested for other versions.
composer require tanedaa/laravel-dynamic-maintenance
Publish the commands, middleware and custom maintenance view
php artisan vendor:publish --tag=laravel-dynamic-maintenance
Register the maintenance
middleware to the routes you want to enable dynamic maintenance on.
Route::middleware('maintenance')->group(function () { Route::get('/', function () { return view('welcome'); }); });
Usage
Enable or disable maintenance mode for specific named routes by providing a comma-separated list of routes to the following commands. Wildcard routes are supported as well. Optionally, you can provide a secret key to bypass maintenance mode.
php artisan down:routes {routes} {--secret}
php artisan up:routes {routes} | all
To bypass maintenance mode, add a query parameter secret
with the secret key you provided when enabling maintenance mode.
http://example.com/home?secret=mySecretKey
Examples
php artisan down:routes welcome, home.contact
php artisan down:routes home.about --secret=mySecretKey
php artisan down.routes api/*
php artisan up:routes home.index, home.contact
php artisan up.routes api/*
php artisan up.routes all
Configuration
Optionally, you can change the maintenance mode Title, Message and HTTP Code in the custom view for the dynamic maintenance routes by adding the following variables to your .env file:
MAINTENANCE_TITLE = 'Service Unavailable' MAINTENANCE_MESSAGE = 'Service Unavailable' MAINTENANCE_CODE = 503