myerscode / templex
A lightweight, regex based template rendering engine
Requires
- php: ^8.4
- myerscode/utilities-files: ^2025
- myerscode/utilities-strings: ^2025
Requires (Dev)
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
- symfony/var-dumper: ^5.3
This package is auto-updated.
Last update: 2026-03-25 15:02:15 UTC
README
A lightweight, regex based template rendering engine for PHP
Why this package is helpful?
Templex lets you define stubs and hydrate them using PHP variables. The engine uses regex for all processing — no eval(), no including and running code as PHP. This means you can safely generate new PHP files, config files, or any text-based content from templates.
Requirements
- PHP 8.5 or higher
Install
composer require myerscode/templex
Quick Start
use Myerscode\Templex\Templex; $templex = new Templex(__DIR__ . '/templates/', 'stub'); echo $templex->render('welcome', ['name' => 'Fred']);
Where templates/welcome.stub contains:
Hello <{ $name }>!
Documentation
- Templates — template syntax, file types, and configuration
- Slots — includes, conditions, loops, switch statements, and variables
Example Guides
Issues and Contributing
We are very happy to receive pull requests to add functionality or fixes.
Bug reports and feature requests can be submitted on the Github Issue Tracker.
Please read the Myerscode contributing guide for information on our Code of Conduct.
License
The MIT License (MIT). Please see License File for more information.