fiveorbs / boiler
A PHP template engine that doesn't require you to learn a new syntax
Requires
- php: >=8.2
- ernst/coverlyzer: ^0.1.1
- symfony/html-sanitizer: ^7.1
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: ^1.0
- fiveorbs/dev: ^1.1
- phpmd/phpmd: ^2.15
- phpunit/phpunit: ^10.5
- staabm/annotate-pull-request-from-checkstyle: ^1.8
- vimeo/psalm: 5.25
This package is auto-updated.
Last update: 2024-11-17 15:42:46 UTC
README
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
Installation
composer require fiveorbs/boiler
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:
<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>');
Run the tests
phpunit --testdox && \ psalm --no-cache --show-info=true && \ phpcs -s -p --ignore=tests/templates src tests
License
Boiler is available under the MIT license.
Copyright © 2022-2024 ebene fünf GmbH. All rights reserved.