PHP code example of contenir / maintenance-laminas-mvc

1. Go to this page and download the library: Download contenir/maintenance-laminas-mvc 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/ */

    

contenir / maintenance-laminas-mvc example snippets


// config/modules.config.php
return [
    // ...other modules
    'Contenir\\Maintenance\\Laminas\\Mvc',
];

// config/autoload/maintenance.local.php
return [
    'maintenance' => [
        // Same path the admin (Contenir CMS) is configured to write.
        'file' => '/var/www/shared/maintenance.local.php',
    ],
];

// config/autoload/maintenance.local.php
return [
    'maintenance' => [
        'file'   => '/var/www/shared/maintenance.local.php',
        'bypass' => static function (\Laminas\Mvc\MvcEvent $event): bool {
            // Return true to let the request through despite maintenance mode.
            // E.g. allow authenticated super-admins:
            $auth = $event->getApplication()->getServiceManager()->get('auth');
            return $auth->hasIdentity() && $auth->getIdentity()->isSuperAdmin();
        },
    ],
];

'maintenance' => [
    'body_template' => file_get_contents(__DIR__ . '/../templates/maintenance.html'),
    'retry_after'   => 1800, // seconds, sent as Retry-After header
],