atournayre / maintenance-bundle
Maintenance bundle for Symfony 4
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.1.3
- atournayre/dotenv-editor: v1.2.*
- symfony/config: 4.4.*
- symfony/console: 4.4.*
- symfony/dependency-injection: 4.4.*
- symfony/http-foundation: 4.4.*
- symfony/http-kernel: 4.4.*
- twig/twig: ^1.41|^2.10|^3.0
Requires (Dev)
Conflicts
This package is auto-updated.
Last update: 2024-10-26 21:39:24 UTC
README
The maintenance bundle helps managing software maintenance.
What this bundle for ?
Use this bundle to enable/disable maintenance and manage options.
Getting Started
$ composer require atournayre/maintenance-bundle
Configuring
Enable the bundle
# config/bundles.php return [ // ... Atournayre\MaintenanceBundle\AtournayreMaintenanceBundle::class => ['all' => true], // ... ];
Configure .env
# .env / .env.local.php return array ( // ... // MAINTENANCE_IS_ENABLED : true / false 'MAINTENANCE_IS_ENABLED' => true, // MAINTENANCE_START_DATETIME : "2021-03-25 00:00:00" / "2021-03-25" 'MAINTENANCE_START_DATETIME' => "2021-03-25 00:00:00", // MAINTENANCE_AUTHORIZED_IPS : "localhost,127.0.0.1" 'MAINTENANCE_AUTHORIZED_IPS' => "localhost", // ... );
Add configuration to services.yaml
# config/services.yaml parameters: atournayre_maintenance.is_enabled: '%env(MAINTENANCE_IS_ENABLED)%' atournayre_maintenance.start_date_time: '%env(MAINTENANCE_START_DATETIME)%' atournayre_maintenance.authorized_ips: '%env(MAINTENANCE_AUTHORIZED_IPS)%'
Overriding templates
Using Symfony 4.4.* ?
$ mkdir -p templates/bundles/AtournayreMaintenanceBundle
$ cp -r vendor/atournayre/maintenance-bundle/Resources/views/. templates/bundles/AtournayreMaintenanceBundle
Templates are now ready for customization!
Usage
Schedule maintenance
Use command below to add maintenance in the future.
$ php bin/console maintenance --start="2021-01-01 12:00:00"
Enable
Use command below to enable maintenance.
$ php bin/console maintenance --enable
Disable
Use command below to disable maintenance.
$ php bin/console maintenance --disable
Add authorized IP
If you want your application to be under maintenance except for specific IPs, use command below.
Works for IPv4 and IPv6.
$ php bin/console maintenance --add-ip="127.0.0.1"
Clean IPs
Use command below to reset authorized IPs.
$ php bin/console maintenance --clean-ips
Dump IPs
Don't remember which IPs are authorized ?
Use command below to dump authorized IPs.
$ php bin/console maintenance --dump-ips
Debug
Use command below to view maintenance configuration.
$ php bin/console maintenance --debug
Multiple
You can use multiple instructions at once.
$ php bin/console maintenance --enable --clean-ips --add-ip="127.0.0.1"
In this example, maintenance will be enabled, old authorized IPs will be reset and a new one will be added.