Back to packages

/templex

A lightweight, regex based template rendering engine for PHP

Installcomposer require myerscode/templex
1Stars
0Forks
87Commits
282Downloads
2026.0.1Latest
MITLicense
PHP100.0%
phptemplatetemplate-enginetemplatestemplatingtemplating-library

Templex

A lightweight, regex based template rendering engine for PHP

Latest Stable VersionTotal DownloadsPHP Version RequireLicenseTestscodecov

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

Bug reports and feature requests can be submitted on the Github Issue Tracker.

Contributing

Contributions are welcome! Please see contributing.md for guidelines on how to contribute to this project.

License

The MIT License (MIT). Please see License File for more information.