MaintenanceBundle v2
Requirements
- PHP
>=7.1
- symfony/framework-bundle
>= 3.4 || ^4.0
- Twig
^2.4
⚠️ Symfony before version 3.4 NOTICE
Please use ^1.x branch versions.
2.x versions is incompatible with versions lower than symfony 3.4
Installation:
Pretty simple with Composer, run:
$ composer require nuboxdevcom/maintenance-bundle
Simply Configuration
Enter your IPs here to allow you to access your site during a maintenance.
In config/ndc_maintenance.yaml
ndc_maintenance:
authorized_ips:
- '127.0.0.1'
- 'your.ip.domain.name.example'
Configuration
Symfony Flex takes care of everything!
How to Use
In your template, add this to let you know if the site is in maintenance
{% if isMaintenanceMode() %}
<p class="text-center bg-danger"><strong>Your site is in maintenance mode...</strong></p>
{% endif %}
isMaintenanceMode() return boolean true or false.
If you want to activate maintenance mode, you will need to call the following method
$this->get('maintenance.service')->enableMaintenanceAction();
Or
$this->get('maintenance.service')->disableMaintenanceAction();
To disable maintenance mode.
If you want to know if maintenance is enabled from a controller, use this method
$this->get('maintenance.service')->isMaintenanceMode();
isMaintenanceMode() return boolean true or false.
How to change the view of maintenance page
If you want to change the view, create a new view file
templates/bundles/NDCMaintenanceBundle/maintenance.html.twig