Skip to content

contenir/maintenance

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

contenir/maintenance

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'));

About

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

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages