PHP code example of contenir / contenir-maintenance
1. Go to this page and download the library: Download contenir/contenir-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/ */
contenir / contenir-maintenance example snippets
use Contenir\Maintenance\MaintenanceState;
$down = MaintenanceState::active('Back online by 5pm AEST.'); // since = now
$down = MaintenanceState::active('Back online by 5pm AEST.', $startedAt); // explicit since
$up = MaintenanceState::inactive();
$custom = new MaintenanceState(active: true, message: 'Down', since: null);
interface MaintenanceRepositoryInterface
{
public function get(): MaintenanceState;
/** @throws RuntimeException If the state cannot be persisted. */
public function save(MaintenanceState $state): void;
}
use Contenir\Maintenance\MaintenanceState;
use Contenir\Maintenance\Repository\FileRepository;
$repo = new FileRepository('/var/www/shared/config/autoload/maintenance.local.php');
$repo->save(MaintenanceState::active('Back online by 5pm AEST.'));
// ... later ...
$repo->save(MaintenanceState::inactive());
$state = $repo->get();
if ($state->active) {
// Render 503 with $state->message
}
use Contenir\Maintenance\MaintenanceState;
use Contenir\Maintenance\Repository\InMemoryRepository;
$repo = new InMemoryRepository(MaintenanceState::active('Down')); // defaults to inactive
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.