curly-deni / laravel-maintenance
Maintenance windows and runtime availability for Laravel applications.
Requires
- php: ^8.4
- laravel/framework: ^11.0||^12.0||^13.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^11.0.0||^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
curly-deni/laravel-maintenance provides scheduled maintenance windows, a file-backed runtime state, middleware for draining new work, and Artisan commands for operating maintenance windows.
Installation
composer require curly-deni/laravel-maintenance php artisan vendor:publish --tag=laravel-maintenance-migrations php artisan migrate
The migration creates operations__maintenance_windows and an internal lock table used to serialize window saves. The optional created_by column is an unsigned ID without a foreign key so the package does not depend on an application's user table.
Publish the configuration to customize the maintenance table name and runtime state locations. The table setting is used by both the Eloquent model and the migration stub; set it before running the migration and keep it (along with lock_table) unchanged for rollbacks.
php artisan vendor:publish --tag=laravel-maintenance-config
Usage
The package registers these commands:
php artisan maintenance:status
php artisan maintenance:status --json
php artisan maintenance:sync-state
php artisan maintenance:cancel {window}
php artisan maintenance:complete {window}
Apply the maintenance.new-work middleware alias to routes that should reject new operations while a window is draining. The package updates the runtime state file when maintenance:sync-state runs and broadcasts Aesis\Maintenance\Events\MaintenanceAvailabilityChanged when the public state changes.
The current runtime state can be read without querying the database:
use Aesis\Maintenance\Facades\Maintenance; $phase = Maintenance::phase(); $state = Maintenance::payload();
Development
composer test
composer analyse
composer format
License
MIT. See LICENSE.md.