nuboxdevcom/maintenance-bundle

Maintenance bundle for Symfony 3.x 4.x

Installs: 47

Dependents: 0

Suggesters: 0

Stars: 2

Watchers: 1

Forks: 0

Language:CSS

Type:symfony-bundle

2.0.3 2018-01-24 14:37 UTC

README

SensioLabsInsight

License Latest Stable Version

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