Warning
This template engine is under active development, so some of the features listed and parts of the documentation may be still experimental, subject to change, or missing.
Boiler is a template engine for PHP 8.2 and above, inspired by Plates. 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 values for enhanced security
- Global template context, making all variables accessible throughout the template
composer require fiveorbs/boiler
Consider this example directory structure:
path
`-- to
`-- templates
`-- page.php
Create a template file at /path/to/templates/page.php
with this content:
<p>ID <?= $id ?></p>
Then initialize the Engine
and render your template:
use FiveOrbs\Boiler\Engine;
$engine = new Engine('/path/to/templates');
$html = $engine->render('page', ['id' => 13]);
assert($html == '<p>ID 13</p>');
phpunit --testdox && \
psalm --no-cache --show-info=true && \
phpcs -s -p --ignore=tests/templates src tests
Boiler is available under the MIT license.
Copyright © 2022-2024 ebene fünf GmbH. All rights reserved.