contenir / maintenance
Framework-agnostic maintenance-mode toggle for Contenir CMS — admin writes, Site reads.
Requires
- php: ^8.1 || ^8.2 || ^8.3
Requires (Dev)
- contenir/config: ^0.1.0
- phpunit/phpunit: ^11.0
- squizlabs/php_codesniffer: ^3.10
Suggests
- contenir/config: Required if you intend to use Repository\FileRepository (admin-side writer). Sites that read state from the merged Laminas/Mezzio config — and use Repository\InMemoryRepository — don't need it.
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'));