contenir/maintenance

Framework-agnostic maintenance-mode toggle for Contenir CMS — admin writes, Site reads.

Maintainers

Package info

github.com/contenir/maintenance

pkg:composer/contenir/maintenance

Statistics

Installs: 7

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.1 2026-05-08 03:37 UTC

This package is auto-updated.

Last update: 2026-05-08 03:45:39 UTC


README

Framework-agnostic maintenance-mode toggle for Contenir CMS.

The CMS writes a maintenance flag (and optional message); the consuming Site (Mezzio, Laminas MVC, anything else) reads it on every request and returns 503 with the message until the flag is cleared.

This package provides the domain — a small immutable state value plus a repository interface, with file-based and in-memory implementations. Framework-specific middleware/listeners come from sibling packages.

Install

composer require contenir/maintenance

Zero runtime dependencies — pure PHP 8.1+.

Usage

Reading state

use Contenir\Maintenance\Repository\FileRepository;

$repo = new FileRepository('/var/www/shared/maintenance.local.php');
$state = $repo->get();

if ($state->active) {
    // Render 503 with $state->message
}

Writing state (admin)

use Contenir\Maintenance\MaintenanceState;

$repo->save(MaintenanceState::active('Back online by 5pm AEST.'));

// ... later ...
$repo->save(MaintenanceState::inactive());

File format

FileRepository reads/writes a PHP file that returns an array:

<?php

return [
    'active' => true,
    'message' => 'Back online by 5pm AEST.',
    'since' => '2026-05-05T03:14:15+00:00',
];

A missing or unreadable file resolves to inactive state, so first-run and permission edge cases don't crash the consumer.

Testing

InMemoryRepository is shipped in src/ so consumers can use it in their own test suites:

use Contenir\Maintenance\Repository\InMemoryRepository;
use Contenir\Maintenance\MaintenanceState;

$repo = new InMemoryRepository(MaintenanceState::active('Down'));