PHPackages                             decodelabs/horizon - 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. [Templating &amp; Views](/categories/templating)
4. /
5. decodelabs/horizon

ActiveLibrary[Templating &amp; Views](/categories/templating)

decodelabs/horizon
==================

Simple HTML view containers

v0.5.2(6mo ago)05942MITPHPPHP ^8.4CI passing

Since Mar 14Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/decodelabs/horizon)[ Packagist](https://packagist.org/packages/decodelabs/horizon)[ RSS](/packages/decodelabs-horizon/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (10)Dependencies (10)Versions (28)Used By (2)

Horizon
=======

[](#horizon)

[![PHP from Packagist](https://camo.githubusercontent.com/ea235a71807d915ac58aa1d4ca309c25d36ee229b593b34299e2d8d44ed079ca/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6465636f64656c6162732f686f72697a6f6e3f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/horizon)[![Latest Version](https://camo.githubusercontent.com/30bd9acb21f775da046575a94a7241d5661b129db16ae8175dd18a74d85b04a9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6465636f64656c6162732f686f72697a6f6e2e7376673f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/horizon)[![Total Downloads](https://camo.githubusercontent.com/04a101971f2f158eb45132a925d0b7f937818af18414d1b46745b9694516044e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6465636f64656c6162732f686f72697a6f6e2e7376673f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/horizon)[![GitHub Workflow Status](https://camo.githubusercontent.com/610bd06345cc48a2792ebfe812effee5b8b5228012c685d0fef5cafa70fa0d59/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6465636f64656c6162732f686f72697a6f6e2f696e746567726174652e796d6c3f6272616e63683d646576656c6f70)](https://github.com/decodelabs/horizon/actions/workflows/integrate.yml)[![PHPStan](https://camo.githubusercontent.com/e25c14ce011edabdd0fbd2e10415b41cc5d66ed11ef3e5b7edd074c5bdd35a2d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d656e61626c65642d3434434331312e7376673f6c6f6e6743616368653d74727565267374796c653d666c6174)](https://github.com/phpstan/phpstan)[![License](https://camo.githubusercontent.com/02f53a4d308c18ac844f59171060c25de7e93d184e7f0e3328b0dc25186215f9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6465636f64656c6162732f686f72697a6f6e3f7374796c653d666c6174)](https://packagist.org/packages/decodelabs/horizon)

### Simple HTML view containers

[](#simple-html-view-containers)

Horizon provides a simple structure for building and rendering HTML views using the `DecodeLabs\Tagged` interfaces.

---

Installation
------------

[](#installation)

This package requires PHP 8.4 or higher.

Install via Composer:

```
composer require decodelabs/horizon
```

Usage
-----

[](#usage)

Programmatically build and render HTML views using the `Page` class:

```
use DecodeLabs\Horizon\Page;
use DecodeLabs\Tagged as Html;

$page = new Page(function($page) {
    $page->title = 'Hello, World!';
    $page->setMeta('description', 'This is a test page');

    $page->addLink(
        key: 'styles',
        rel: 'stylesheet',
        href: '/styles.css'
    );

    $page->addLink(
        key: 'favicon',
        rel: 'icon',
        href: '/favicon.ico'
    );

    $page->addBodyScript(
        key: 'bundle',
        src: '/bundle-45346534.js'
    );

    $page->bodyTag->addClass('section-home');

    yield Html::{'h1'}('Hello, World!');
    yield Html::{'p'}('This is a test page');
});
```

### Decorators

[](#decorators)

Horizon provides a simple decorator system for adding additional functionality to your pages. Decorators must be findable by `Archetype` - either in `DecodeLabs\Horizon\Decorator` or in a namespace registered in the `Archetype` namespace map.

```
namespace DecodeLabs\Horizon\Decorator;

use DecodeLabs\Horizon\Decorator;
use DecodeLabs\Horizon\Page;

class MyDecorator implements Decorator
{
    public function decorate(
        Page $page, // Require parameter
        string $basePath // Decorator-specific parameter
    ): void {
        $page->title = 'My Decorated Page';

        $page->addBodyScript(
            key: 'analytics',
            src: $basePath.'/analytics.js'
        );
    }
}

$page = new Page(function($page) {
    yield Html::{'h1'}('Hello, World!');
    yield Html::{'p'}('This is a test page');
});

$page->decorate('MyDecorator', '/base/path');
```

### Harvest Transformer

[](#harvest-transformer)

Horizon includes a `Harvest` transformer that can be used to convert a `Page` instance into a PSR-7 HTTP Response during the `Harvest` request lifecycle.

Harvest Transformers should be managed by the HTTP Middleware that needs to transform Responses, for example `Greenleaf` will transparently call `transform()` for the return value of a `Greenleaf Action`.

The result is that you can return a `Page` instance from a `Greenleaf Action` and it will be automatically transformed into a PSR-7 Response.

```
use DecodeLabs\Greenleaf\Action;
use DecodeLabs\Greenleaf\Action\ByMethodTrait;
use DecodeLabs\Horizon\Harvest;

class MyAction implements Action
{
    use ByMethodTrait;

    public function get(): Page
    {
        return new Page(function() {
            yield 'My content';
        });
    }
}
```

Licensing
---------

[](#licensing)

Horizon is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance69

Regular maintenance activity

Popularity14

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~9 days

Recently: every ~21 days

Total

26

Last Release

202d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a241d64d12b3b5ee94197862ec1ec30b82ed2efa34a0cd7f4c3565a021daddd?d=identicon)[betterthanclay](/maintainers/betterthanclay)

---

Top Contributors

[![betterthanclay](https://avatars.githubusercontent.com/u/1273586?v=4)](https://github.com/betterthanclay "betterthanclay (94 commits)")

---

Tags

html-generatorphpview

### Embed Badge

![Health badge](/badges/decodelabs-horizon/health.svg)

```
[![Health](https://phpackages.com/badges/decodelabs-horizon/health.svg)](https://phpackages.com/packages/decodelabs-horizon)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
