PHPackages                             myerscode/templex - 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. myerscode/templex

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

myerscode/templex
=================

A lightweight, regex based template rendering engine

2025.1.0(9mo ago)125[3 PRs](https://github.com/myerscode/templex/pulls)MITPHPPHP ^8.4CI passing

Since Nov 28Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/myerscode/templex)[ Packagist](https://packagist.org/packages/myerscode/templex)[ RSS](/packages/myerscode-templex/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (12)Used By (0)

Templex
=======

[](#templex)

> A lightweight, regex based template rendering engine for PHP

[![Latest Stable Version](https://camo.githubusercontent.com/a21edd39446f2dd4851450e44ee0e12236fdff5f6e544a6e0d46abdec414e46f/68747470733a2f2f706f7365722e707567782e6f72672f6d79657273636f64652f74656d706c65782f762f737461626c65)](https://packagist.org/packages/myerscode/templex)[![PHP Version Require](https://camo.githubusercontent.com/9ea880b84a64f3187379e66e1f5781a894d0c1395e3ab9723770c81b88155c91/687474703a2f2f706f7365722e707567782e6f72672f6d79657273636f64652f74656d706c65782f726571756972652f706870)](https://packagist.org/packages/myerscode/templex)[![Total Downloads](https://camo.githubusercontent.com/58790b44cf4fbdb889eb12f2f5d1605565babcc9cbda40818f4c8ac537b56003/68747470733a2f2f706f7365722e707567782e6f72672f6d79657273636f64652f74656d706c65782f646f776e6c6f616473)](https://packagist.org/packages/myerscode/templex)[![License](https://camo.githubusercontent.com/a4eeed34a5dd7113be899ac5198f2b606e0db551bf4311bf90e005881c5d538d/68747470733a2f2f706f7365722e707567782e6f72672f6d79657273636f64652f74656d706c65782f6c6963656e7365)](https://packagist.org/packages/myerscode/templex)[![Tests](https://github.com/myerscode/templex/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/myerscode/templex/actions/workflows/tests.yml/badge.svg?branch=main)[![codecov](https://camo.githubusercontent.com/e27269440a5bf77d3c9bf2d58b1954fa6ffa6aaca2e3163dac71edc7f3f5b611/68747470733a2f2f636f6465636f762e696f2f67682f6d79657273636f64652f74656d706c65782f67726170682f62616467652e7376673f746f6b656e3d59523059485645524e56)](https://codecov.io/gh/myerscode/templex)

Why this package is helpful?
----------------------------

[](#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
------------

[](#requirements)

- PHP 8.5 or higher

Install
-------

[](#install)

```
composer require myerscode/templex
```

Quick Start
-----------

[](#quick-start)

```
use Myerscode\Templex\Templex;

$templex = new Templex(__DIR__ . '/templates/', 'stub');

echo $templex->render('welcome', ['name' => 'Fred']);
```

Where `templates/welcome.stub` contains:

```
Hello !

```

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

[](#documentation)

- [Templates](docs/templates.md) — template syntax, file types, and configuration
- [Slots](docs/slots.md) — includes, conditions, loops, switch statements, and variables

### Example Guides

[](#example-guides)

- [Condition Examples](docs/condition-examples.md)
- [Foreach Examples](docs/foreach-examples.md)
- [For Loop Examples](docs/for-loop-examples.md)
- [Switch Statement Examples](docs/switch-examples.md)

Issues and Contributing
-----------------------

[](#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](https://github.com/myerscode/templex/issues).

Please read the Myerscode [contributing](https://github.com/myerscode/docs/blob/main/CONTRIBUTING.md) guide for information on our Code of Conduct.

License
-------

[](#license)

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

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance76

Regular maintenance activity

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity74

Established project with proven stability

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

Recently: every ~335 days

Total

6

Last Release

276d ago

Major Versions

1.1.2 → 2025.0.02025-02-03

PHP version history (2 changes)1.0.0PHP ^8.0

2025.0.0PHP ^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/a3d9923c8c4269fbe7076613da7e814719743f643cb115b441ccee8aeaa1290e?d=identicon)[oniice](/maintainers/oniice)

---

Top Contributors

[![oniice](https://avatars.githubusercontent.com/u/2676321?v=4)](https://github.com/oniice "oniice (70 commits)")

---

Tags

templatetemplatingtemplate enginephp templateregex tempalte

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/myerscode-templex/health.svg)

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

###  Alternatives

[eftec/bladeone

The standalone version Blade Template Engine from Laravel in a single php file

8208.4M87](/packages/eftec-bladeone)[fenom/fenom

Fenom - excellent template engine for PHP

44395.5k19](/packages/fenom-fenom)[duncan3dc/blade

Use Laravel Blade templates without the full Laravel framework

160499.5k24](/packages/duncan3dc-blade)[talesoft/tale-pug

A clean, lightweight and easy-to-use templating engine for PHP based on Pug, formerly Jade

319.4k3](/packages/talesoft-tale-pug)[leitsch/kirby-blade

Enable Laravel Blade Template Engine for Kirby 4 and Kirby 5

219.2k](/packages/leitsch-kirby-blade)[eftec/bladeonehtml

The standalone version Blade Template Engine from Laravel in a single php file

1018.1k5](/packages/eftec-bladeonehtml)

PHPackages © 2026

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