composer require artgris/maintenance-bundle
config/packages/artgris_maintenance.yaml:
artgris_maintenance:
enable: true
ips: ["127.0.0.1", "::1"] # Allow local access
php bin/console cache:clear
Deploy a new feature? Enable maintenance before pushing:
# Temporarily allow your IP (prod)
php bin/console cache:clear
# Then disable after deployment
Pre-Deployment Checklist:
enable: true).Dynamic Maintenance Pages:
Override templates/bundles/ArtgrisMaintenanceBundle/maintenance.html.twig to customize:
{% extends "@ArtgrisMaintenance/maintenance.html.twig" %}
{% block content %}
<h1>{{ 'maintenance.title'|trans }}</h1>
<p>{{ 'maintenance.message'|trans }}</p>
{% endblock %}
Tip: Use translation keys for multilingual support.
Environment-Specific Config:
Use Symfony’s environment variables or %env() in artgris_maintenance.yaml:
ips: ["%MAINTENANCE_WHITELIST_IPS%"]
API Maintenance: Extend the bundle to return JSON for API routes (see Gotchas for hooks).
kernel.request listener).Cache Clearing:
IP Whitelisting:
ips: ["192.168.1.0/24"]
Dev Environment:
dev—test locally with:
enable: true
ips: ["127.0.0.1"]
HTTP Status Code:
503 may break SEO. Use 200 with a meta tag for crawlers:
<meta name="robots" content="noindex">
php bin/console debug:config artgris_maintenance
enable: false or override the listener (see Extension Points).Custom Logic:
Override the MaintenanceListener to add conditions (e.g., time-based maintenance):
// src/EventListener/CustomMaintenanceListener.php
use Artgris\MaintenanceBundle\EventListener\MaintenanceListener;
class CustomMaintenanceListener extends MaintenanceListener {
public function isMaintenance(): bool {
return parent::isMaintenance() && $this->isScheduledMaintenance();
}
}
Register it in config/services.yaml:
services:
App\EventListener\CustomMaintenanceListener:
tags: [kernel.event_listener, { event: kernel.request, method: onKernelRequest }]
API-Specific Responses: Extend the bundle to return JSON for API routes:
{% if request.isXmlHttpRequest %}
{{ { 'error': 'Service Unavailable', 'code': 503 }|json_encode|raw }}
{% else %}
{% include '@ArtgrisMaintenance/maintenance.html.twig' %}
{% endif %}
Multi-Tenant Maintenance:
Use a database-backed whitelist (e.g., tenants table) and override isAuthorized() in the listener.
ips array: Maintenance affects all IPs (use ips: [] to disable for everyone).ips are case-sensitive (use lowercase).config/packages/ is used (not config/bundles.php).How can I help you explore Laravel packages today?