PHP code example of nimblephp / maintenance

1. Go to this page and download the library: Download nimblephp/maintenance library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nimblephp / maintenance example snippets


use NimblePHP\Maintenance\Maintenance;

// turn on (optionally with a custom message)
Maintenance::enable('Back in 10 minutes.');

// let yourself through
Maintenance::allowIp('127.0.0.1');

// status / config
Maintenance::isEnabled();        // bool
Maintenance::allowedIps();       // ['127.0.0.1', ...]
Maintenance::message();          // string
Maintenance::isAllowed($ip);     // true when off or IP allow-listed

// turn off
Maintenance::disable();

Maintenance::setView('test');
Maintenance::clearView();
bash
php vendor/bin/nimble maintenance:on                       # enable
php vendor/bin/nimble maintenance:on --message="Back at 18:00"
php vendor/bin/nimble maintenance:allow-ip 127.0.0.1       # let yourself through
php vendor/bin/nimble maintenance:status                   # show state
php vendor/bin/nimble maintenance:disallow-ip 127.0.0.1
php vendor/bin/nimble maintenance:off                      # disable
bash
php vendor/bin/nimble maintenance:view test          # Twig: App/View/test.twig | base: App/View/test.phtml
php vendor/bin/nimble maintenance:view errors/down   # nested: App/View/errors/down.{twig|phtml}
php vendor/bin/nimble maintenance:view --clear       # back to the bundled default