LaravelPackages.net
Acme Inc.
Toggle sidebar
tanedaa/laravel-dynamic-maintenance

A Laravel package to enable maintenance mode for specific named routes

8
1
1.2.0
About tanedaa/laravel-dynamic-maintenance

tanedaa/laravel-dynamic-maintenance is a Laravel package for a laravel package to enable maintenance mode for specific named routes. It currently has 1 GitHub stars and 8 downloads on Packagist (latest version 1.2.0). Install it with composer require tanedaa/laravel-dynamic-maintenance. Discover more Laravel packages by tanedaa or browse all Laravel packages to compare alternatives.

Last updated

Laravel Dynamic Maintenance

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
Comments