PHPackages                             celema/boiler - 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. celema/boiler

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

celema/boiler
=============

A PHP template engine that doesn't require you to learn a new syntax

0.8.0(2w ago)052MITPHPPHP ^8.5CI passing

Since Jan 25Pushed 1w ago1 watchersCompare

[ Source](https://github.com/celemas/boiler)[ Packagist](https://packagist.org/packages/celema/boiler)[ Docs](https://celema.dev/boiler)[ RSS](/packages/celema-boiler/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependencies (4)Versions (14)Used By (0)

Celema Boiler
=============

[](#celema-boiler)

[![ci](https://camo.githubusercontent.com/f1faaa205c5be6caaf3b50dcd760a81f63744d1b030909a9d0e612ca86ba5600/68747470733a2f2f636f6465666c6f652e636f6d2f63656c656d612f626f696c65722f6261646765732f776f726b666c6f77732f63692e796d6c2f62616467652e7376673f7374796c653d666c6174266c6f676f3d666f7267656a6f266c6f676f436f6c6f723d7768697465266c6162656c3d6369)](https://codefloe.com/celema/boiler/actions)[![code coverage](https://camo.githubusercontent.com/b50a6a4edf7dff0dddcb8aac3911b05487eb34069fe152bf3a9a91989684bbcb/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246636f762e63656c656d612e64657625324663656c656d61253246626f696c6572253246636f646525324662616467652e6a736f6e)](https://cov.celema.dev/celema/boiler/code)[![type coverage](https://camo.githubusercontent.com/a9ff973ad4f2962e48d2518df6265ee8c4e8d6b4ec4a84930f4579924a687e38/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246636f762e63656c656d612e64657625324663656c656d61253246626f696c6572253246747970657325324662616467652d636f7665722e6a736f6e)](https://cov.celema.dev/celema/boiler/types)[![psalm level](https://camo.githubusercontent.com/8c886b054c073b768b33fcb4a4d7db8af2eefda9ef122e9c92541aaa0076cccc/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d6874747073253341253246253246636f762e63656c656d612e64657625324663656c656d61253246626f696c6572253246747970657325324662616467652d6c6576656c2e6a736f6e)](https://cov.celema.dev/celema/boiler/types)[![Software License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE.md)

Boiler is a small template engine for PHP 8.5+, inspired by [Plates](https://platesphp.com/). Like Plates, it uses native PHP as its templating language rather than introducing a custom syntax.

Key differences from Plates:

- Automatic escaping of strings and [Stringable](https://www.php.net/manual/en/class.stringable.php) values for enhanced security
- Inherited render context across layouts, inserts, and section captures; custom insert or layout context merges on top and overrides duplicate keys

Other highlights:

- Layouts, inserts/partials, and sections, including append and prepend support
- Wrapper-driven escaping and a pluggable filter system for value transformations
- Custom template methods, including safe HTML helpers, and optional trusted classes

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

[](#installation)

```
composer require celema/boiler
```

Install Symfony's HTML sanitizer when you want Boiler's built-in `sanitize` filter:

```
composer require symfony/html-sanitizer
```

Documentation
-------------

[](#documentation)

Start here: [docs/index.md](docs/index.md).

### Topic overview

[](#topic-overview)

- [Quick start](docs/quickstart.md)
- [Engine](docs/engine.md)
- [Rendering templates](docs/rendering.md)
- [Displaying values](docs/values.md)
- [Layouts](docs/layouts.md)
- [Inserts](docs/inserts.md)
- [Sections](docs/sections.md)
- [Slots](docs/slots.md)
- [Template](docs/template.md)

Quick start
-----------

[](#quick-start)

Consider this example directory structure:

```
path
`-- to
    `-- templates
        `-- page.php

```

Create a template file at `/path/to/templates/page.php` with this content:

```
ID
```

Then initialize the `Engine` and render your template:

```
use Celema\Boiler\Engine;

$engine = Engine::create('/path/to/templates');
$html = $engine->render('page', ['id' => 13]);

assert($html === 'ID 13');
```

Common patterns
---------------

[](#common-patterns)

Render from multiple directories, optionally with namespaces:

```
$engine = Engine::create([
    'theme' => '/path/to/theme',
    'app' => '/path/to/templates',
]);

// Renders the first match (theme overrides app)
$engine->render('page');

// Force a specific namespace
$engine->render('app:page');
```

Control escaping:

```
$engine = Engine::create('/path/to/templates');
$engine->render('page');
$engine->renderUnescaped('page');

$engine = Engine::unescaped('/path/to/templates');
$engine->render('page');
$engine->renderEscaped('page');
```

Configure shared defaults and trusted classes:

```
$engine = Engine::create(
    '/path/to/templates',
    defaults: ['siteName' => 'Celema'],
    trusted: [TrustedHtml::class],
);
```

Register custom template methods with `method()`. Pass `safe: true` when a helper returns safe HTML:

```
use function App\Template\icon;

$engine = Engine::create('/path/to/templates')
    ->method('icon', icon(...), safe: true);
```

Methods are available as `$this->icon()` inside templates, inserts, and layouts.

Register custom filters with the fluent `filter()` method:

```
use Celema\Boiler\Contract\Filter;

$engine = Engine::create('/path/to/templates')
    ->filter('upper', new class implements Filter {
        public function apply(string $value, mixed ...$args): string
        {
            return strtoupper($value);
        }

        public function safe(): bool
        {
            return false;
        }
    });
```

Filters are available as virtual methods on wrapped string values in templates. In escaped renders, Boiler wraps string values for you. When you need filters on a raw value inside a template, call `$this->wrap($value)` first. Boiler ships with built-in `lower`, `upper`, `stripTags`, and `trim` filters, and registers `sanitize` automatically when `symfony/html-sanitizer` is installed.

For filter safety rules and advanced wrapper, filter, and escaper customization, see [displaying values](docs/values.md), [engine](docs/engine.md), and [template](docs/template.md).

Template helpers available via `$this` inside templates:

- `$this->layout('layout')`
- `$this->insert('partial', ['value' => '...'])`
- `$this->slot(['value' => '...'])` / `$this->hasSlot()` inside inserted templates that receive a closure or `Slot::template()` slot
- `$this->begin('name')` / `$this->append('name')` / `$this->prepend('name')` / `$this->end()`
- `$this->section('name', 'default')` / `$this->has('name')`
- `$this->unwrap($value)` when you need the original value instead of the escaped wrapper
- `$this->escape($value)` and `$this->wrap($value)` when you need proxy behavior such as string filters on a raw value

Wrapped values are proxy objects, so `===` against a plain value is always false, and native string functions such as `str_contains()` silently operate on the escaped text. Compare and test through the proxy's predicate methods instead, which work on the raw value: `$item->status->is(Status::Active)`, `$status->in(['draft', 'pending'])`, `$title->contains('&')`, `$url->startsWith('https://')`, `$file->endsWith('.pdf')`, `$slug->matches('/^[a-z0-9-]+$/')`, and `$tags->contains('featured')` on wrapped arrays. See [comparing wrapped values](docs/values.md#comparing-wrapped-values).

Error handling
--------------

[](#error-handling)

Boiler fails fast on invalid lookups and render state, such as missing templates, invalid template names, duplicate layouts, unclosed sections, missing slots, or unknown methods and filters. See [rendering templates](docs/rendering.md), [layouts](docs/layouts.md), [sections](docs/sections.md), [slots](docs/slots.md), and [template](docs/template.md) for the exact rules.

Benchmark
---------

[](#benchmark)

Boiler includes a canonical benchmark in [`bench/`](bench/) that renders a feature-rich catalog page and is used mainly to catch performance regressions during development.

Run it with `composer benchmark`. For benchmark scope, caveats, and detailed usage, see [`bench/README.md`](bench/README.md).

Run the tests
-------------

[](#run-the-tests)

```
composer test
composer lint
composer types
composer docs:lint
```

For the PHP verification pipeline, run:

```
composer ci
```

`composer ci:full` additionally lints Markdown and requires Node (`npx`).

License
-------

[](#license)

This project is licensed under the [MIT license](LICENSE.md).

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance97

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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 ~16 days

Recently: every ~23 days

Total

13

Last Release

19d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0c15f1690b643e5cbf205fd28f3b2ebb6c7448d34774bb92b7952150c901a689?d=identicon)[ernstla](/maintainers/ernstla)

---

Top Contributors

[![ernstla](https://avatars.githubusercontent.com/u/683620?v=4)](https://github.com/ernstla "ernstla (503 commits)")

---

Tags

templatingtemplatescelema

### Embed Badge

![Health badge](/badges/celema-boiler/health.svg)

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

###  Alternatives

[twig/twig

Twig, the flexible, fast, and secure template language for PHP

8.7k482.4M8.0k](/packages/twig-twig)[league/plates

Plates, the native PHP template system that's fast, easy to use and easy to extend.

1.5k6.4M301](/packages/league-plates)[mustache/mustache

A Mustache implementation in PHP.

3.3k49.7M340](/packages/mustache-mustache)[smarty/smarty

Smarty - the compiling PHP template engine

2.3k43.6M507](/packages/smarty-smarty)[laminas/laminas-view

Fast and type safe HTML templating library with a flexible plugin system supporting multistep template composition

7529.9M283](/packages/laminas-laminas-view)[shoot/shoot

Shoot aims to make providing data to your templates more manageable

40229.9k2](/packages/shoot-shoot)

PHPackages © 2026

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