PHPackages                             contenir/errors - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. contenir/errors

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

contenir/errors
===============

Framework-agnostic admin-authored error-page content for Contenir CMS — admin writes per-status titles and bodies, Site renders.

v0.1.1(1mo ago)0341MITPHPPHP ^8.1 || ^8.2 || ^8.3

Since May 6Pushed 1mo agoCompare

[ Source](https://github.com/contenir/errors)[ Packagist](https://packagist.org/packages/contenir/errors)[ RSS](/packages/contenir-errors/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (3)Versions (3)Used By (1)

contenir/errors
===============

[](#contenirerrors)

Framework-agnostic admin-authored error-page content for [Contenir CMS](https://github.com/contenir).

The CMS lets an operator author per-status error pages (404, 500, 403, …). The consuming Site (Mezzio, Laminas MVC, anything else) reads those pages on every error and replaces the framework's default rendering with on-brand content.

This package provides the *domain* — an immutable per-status value plus a repository interface, with file-based and in-memory implementations. Framework-specific listeners/middleware come from sibling packages (e.g. `contenir/errors-laminas-mvc`).

Install
-------

[](#install)

```
composer require contenir/errors
```

Zero runtime dependencies — pure PHP 8.1+.

Usage
-----

[](#usage)

### Reading pages

[](#reading-pages)

```
use Contenir\Errors\Repository\FileRepository;

$repo = new FileRepository('/var/www/shared/errors.local.php');
$page = $repo->get(404);

if ($page !== null && ! $page->isEmpty()) {
    // Render with $page->title and $page->body
}
```

### Writing pages (admin)

[](#writing-pages-admin)

```
use Contenir\Errors\ErrorPage;

$repo->save(new ErrorPage(404, 'Page not found', 'Try the homepage.'));
$repo->delete(404);
```

The body is expected to be a *sanitized* HTML fragment — inline elements only, no scripts/styles. Sanitization is the writer's responsibility; readers render raw and trust the contract.

### File format

[](#file-format)

`FileRepository` reads/writes a PHP file that returns an array indexed by HTTP status code:

```
