synolia / sylius-maintenance-plugin
Plugin for Sylius when your website is under maintenance
Package info
github.com/synolia/SyliusMaintenancePlugin
Type:sylius-plugin
pkg:composer/synolia/sylius-maintenance-plugin
Requires
- php: ^8.3
- jaybizzle/crawler-detect: ^1.2
- sylius/sylius: ^2.2
- webmozart/assert: ^1.11
Requires (Dev)
- dbrekelmans/bdi: ^1.0
- friendsoftwig/twigcs: ^6.4.0
- php-parallel-lint/php-parallel-lint: ^1.4
- phpmd/phpmd: ^3.0
- phpro/grumphp: ^2.0
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpstan/phpstan-webmozart-assert: ^2.0
- phpunit/phpunit: ^9.5
- povils/phpmnd: ^3.0
- rector/rector: ^2.0
- squizlabs/php_codesniffer: ^3.11
- sylius-labs/coding-standard: ^4.3
- sylius/test-application: ~2.2.0@alpha || ~2.3.0@alpha
- symfony/browser-kit: ^6.4 | ^7.4 | ^8.0
- symfony/css-selector: ^6.4 | ^7.4 | ^8.0
- symfony/debug-bundle: ^6.4 | ^7.4 | ^8.0
- symfony/dotenv: ^6.4 | ^7.4 | ^8.0
- symfony/intl: ^6.4 | ^7.4 | ^8.0
- symfony/panther: ^2.0
- symfony/web-profiler-bundle: ^6.4 | ^7.4 | ^8.0
Suggests
None
Provides
None
Conflicts
- sylius/test-application: v2.0.0-ALPHA.1
Replaces
None
This package is auto-updated.
Last update: 2026-12-02 08:35:25 UTC
README
Sylius Maintenance Plugin
Features
When your website is under maintenance, the plugin lets you:
- Show a maintenance page (HTTP 503) instead of your shop, with a custom message if you want one.
- Let some IP addresses, or anyone holding a secret token, browse the shop as usual.
- Let search bots through, to avoid a negative impact on SEO.
- Keep the admin area available, or close it too.
- Put only some channels under maintenance on a multi-channel store.
- Schedule the maintenance with a start date, an end date, or both.
- Turn the maintenance on and off from the console or from the Sylius back-office.
Requirements
| Version | |
|---|---|
| PHP | ^8.3 |
| Sylius | ^2.2 |
| Symfony | ^6.4 || ^7.4 || ^8.0 |
Installation
-
Add the bundle and dependencies in your composer.json :
composer require synolia/sylius-maintenance-plugin
-
Import routing in your
config/routes.yamlfile:synolia_maintenance: resource: "@SynoliaSyliusMaintenancePlugin/config/routes/admin_routing.yaml" prefix: '/%sylius_admin.path_name%'
-
Import twig hooks from config in your
config/packages/maintenance.yamlfile:imports: - { resource: "@SynoliaSyliusMaintenancePlugin/config/config.yaml" }
-
Clear cache
php bin/console cache:clear
Usage
The maintenance is driven by a maintenance.yaml file at the root of your project.
While this file exists, the website is under maintenance, unless it contains enabled: false.
You can write it by hand, or let the console commands and the back-office write it for you.
Warning
On a store with several channels, a maintenance.yaml without channels puts no channel under maintenance.
List the channels to put under maintenance, or use maintenance:enable, which lists all of them for you.
Configuration file
Every key is optional:
# maintenance.yaml enabled: true # false keeps the configuration without putting the website under maintenance ips: [172.16.254.1, 192.0.0.255] # IP addresses allowed to browse the shop channels: [FASHION_WEB] # multi-channel stores only, see below scheduler: start_date: '2026-12-01 22:00:00' # format Y-m-d H:i:s end_date: '2026-12-02 06:00:00' custom_message: '<p>We are back soon!</p>' # HTML is allowed, replaces the default message token: 'a-long-random-secret' # see "Access token" below allow_bots: true # default: false allow_admins: false # default: true
On a store with several channels, only the channels listed in channels are under maintenance:
a file without channels puts no channel under maintenance (see the warning above). With a single channel, channels is ignored.
Console commands
# Put all channels under maintenance and keep the admin area open. # The IP addresses, message, token and schedule already configured are kept. php bin/console maintenance:enable # Same, and allow some IP addresses (separated with a space) php bin/console maintenance:enable 172.16.254.1 255.255.255.255 192.0.0.255 # Same, and close the admin area too php bin/console maintenance:enable --disable-admin # Turn the maintenance off, keeping the configuration for next time php bin/console maintenance:disable # Turn the maintenance off and remove the configuration file php bin/console maintenance:disable --clear
Back-office
The configuration page is in Configuration > Maintenance. From there you can:
- enable or disable the maintenance;
- choose the channels under maintenance (multi-channel stores only);
- allow IP addresses;
- write a custom message;
- set a start date and an end date;
- let search bots and admins through;
- store the secret token in your session, to browse the shop during the maintenance.
A secret token is generated when the back-office or maintenance:enable creates the maintenance.yaml file.
A file written by hand has no token unless you add a token key.
Access token
When a token is configured, a request bypasses the maintenance if it carries the token:
- as a query parameter:
?synolia_maintenance_token=<token>; - as a
synolia_maintenance_tokenheader; - in the session, using the button of the back-office page.
Without a configured token, no request can bypass the maintenance this way.
What visitors get
- HTML requests get the maintenance page with a 503 status, including on URLs that do not exist.
- Requests sent with a JSON
Content-Typeget a 503 response:{"key": "maintenance", "message": "<custom message>"}. - The Symfony profiler (
/_profiler,/_wdt) stays reachable.
Customize the maintenance page
Override the template in templates/bundles/SynoliaSyliusMaintenancePlugin/maintenance.html.twig.
It receives custom_message, an empty string when no custom message is set.
To translate the page, use translation keys in your template. The default message uses the maintenance.ui.message key.
The page is translated with the locale of the requested URL. On a URL that does not exist, that locale is unknown,
so you may prefer the language of the browser:
{% set locale = app.request.preferredLanguage(['en', 'fr', 'de']) %}
{{ 'maintenance.ui.message'|trans({}, 'messages', locale) }}
Maintenance file in another directory
Set the directory, relative to your project root, in your .env:
SYNOLIA_MAINTENANCE_DIR=var/maintenance
Cache the configuration file
# .env SYNOLIA_MAINTENANCE_CACHE=30 # ttl in seconds
Then configure the synolia_maintenance.cache pool, for example with Redis:
# config/packages/prod/cache.yaml framework: cache: pools: synolia_maintenance.cache: adapter: cache.adapter.redis
The console commands and the back-office clear this cache when they change the configuration.
Add your own rule
Each rule is a checker implementing Synolia\SyliusMaintenancePlugin\Checker\IsMaintenanceCheckerInterface.
Checkers are registered automatically and run by decreasing priority. As soon as one of them returns
IsMaintenanceVoterInterface::ACCESS_GRANTED, the request is let through. Return IsMaintenanceVoterInterface::ACCESS_DENIED
to let the next checkers decide.
use Symfony\Component\HttpFoundation\Request; use Synolia\SyliusMaintenancePlugin\Checker\IsMaintenanceCheckerInterface; use Synolia\SyliusMaintenancePlugin\Model\MaintenanceConfiguration; use Synolia\SyliusMaintenancePlugin\Voter\IsMaintenanceVoterInterface; final class HealthCheckChecker implements IsMaintenanceCheckerInterface { public static function getDefaultPriority(): int { return 95; } public function isMaintenance(MaintenanceConfiguration $configuration, Request $request): bool { return '/health' === $request->getPathInfo() ? IsMaintenanceVoterInterface::ACCESS_GRANTED : IsMaintenanceVoterInterface::ACCESS_DENIED; } }
The built-in checkers have the following priorities: enabled (100), IP addresses and bots (90), schedule (80), admin area (70), channels (60), profiler (30) and token (20).
Development
See How to contribute.
License
This library is under the EUPL-1.2 license.
Credits
Developed by Synolia.
