contenir / contenir-config
Framework-agnostic PHP-array config file reader/writer with atomic writes and opcache invalidation. Adapted from Laminas\Config.
Requires
- php: ~8.3.0 || ~8.4.0 || ~8.5.0
- webimpress/safe-writer: ^2.2
Requires (Dev)
- infection/infection: ^0.34.1
- php-db/phpdb-qa-tools: 0.1.x-dev
- phpunit/phpunit: ^11.5.42
Suggests
None
Provides
None
Conflicts
None
Replaces
- contenir/config: v2.1.0
This package is auto-updated.
Last update: 2026-10-07 03:10:11 UTC
README
Formerly contenir/config; the old package is abandoned in favour of this one.
Framework-agnostic PHP-array config file reader and writer for Contenir CMS.
Reads and writes the <?php return [...]; config files that get merged into a Laminas/Mezzio site's configuration. Designed for the admin-writes / Site-reads pattern used by sibling packages like contenir/contenir-cache, contenir/contenir-maintenance, and contenir/contenir-errors.
The reader is tolerant — a missing, unreadable, or syntactically broken file resolves to an empty array rather than throwing, so first-run consumers can ask for state before any has been written. The writer is atomic — partial writes are never visible to readers, and concurrent writers can't race during the write/rename window.
Install
composer require contenir/contenir-config
Requires PHP 8.3, 8.4 or 8.5. The 0.x releases, which support PHP 8.1, remain
available from the 0.x branch and v0.* tags; see UPGRADE-2.0.md.
Usage
Reading
use Contenir\Config\Reader\PhpArray as ConfigReader; $config = ConfigReader::fromFile('/var/www/shared/pagecache.local.php');
$config is always an array — empty if the file doesn't exist, is unreadable, or contains a parse error.
Writing
use Contenir\Config\Writer\PhpArray as ConfigWriter; ConfigWriter::toFile($path, $config);
The optional third argument is a domain label that gets interpolated into error messages — sibling packages pass things like 'cache control', 'maintenance state', 'error pages' so failures surface with consumer-meaningful wording. Save errors throw Contenir\Config\Exception\WriteException, which extends \RuntimeException.
Development
The QA toolchain is contenir/contenir-qa-tools.
Mago is a standalone binary, installed
separately (brew install mago).
composer check # everything below composer cs-check # mago format --check && mago lint composer static-analysis # mago analyze composer test # unit suite: pure rendering, no I/O composer test-integration # integration suite: real filesystem in a temp directory composer test-coverage # both suites, clover.xml for Codecov composer mutation-test # Infection mutation testing over both suites
License
MIT. See LICENSE.