PHPackages                             irfantoor/template-engine - 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. irfantoor/template-engine

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

irfantoor/template-engine
=========================

A simple, small and smart template engine

0.3.3(3y ago)244MITPHPPHP &gt;= 7.3

Since Mar 25Pushed 3y ago1 watchersCompare

[ Source](https://github.com/irfantoor/template-engine)[ Packagist](https://packagist.org/packages/irfantoor/template-engine)[ RSS](/packages/irfantoor-template-engine/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (1)Versions (14)Used By (0)

IrfanTOOR\\TemplateEngine
=========================

[](#irfantoortemplateengine)

A simple and small template engine.

Quick start
===========

[](#quick-start)

Installation
------------

[](#installation)

Installation or inclusion in your project:

```
$ composer require irfantoor/template-engine
```

To test the template engine:

```
$ vendor/bin/test
```

Creating the Template Engine:
-----------------------------

[](#creating-the-template-engine)

```
$te = new IrfanTOOR\TemplateEngine([
    'max_depth' => 3, # defaults to 3
    'base_path'  => 'your/path/to/template/files/',
]);
```

Processing Text
---------------

[](#processing-text)

```
$text = "{$greeting} {$user}!";
$data = [
    'greeting' => 'Hello',
    'user' => 'World',
];

echo $te->processText($text, $data);
```

Processing File
---------------

[](#processing-file)

```
# home.php
{$title}

{@foreach ($list as $item):}
{$item}
{@endforeach}

```

```
$data = [
    'title' => 'Fruits',
    'list' => [
        'Apple',
        'Orange',
        'Blackberry',
        'Raspberry',
    ],
];

echo $te->processFile("home.php", $data);
```

Template
--------

[](#template)

### Comments

[](#comments)

**format: {#...}**

```
{# its a comment!}
{#anything here including the external brackets are removed from the output}
```

### Tokens

[](#tokens)

**format: {$...}**

The tokens are replaced with the values provided by the passed data array.

```
{$name['first']} {$name['last']}
{$address[0]}
{$address[1]}
tel: {$tel}
email: {$email}

```

**format: {!$...}**The tokens are replaced with tags are replaced with value, without doing any html special character conversion. It helps in including the html tags etc. which are displayed as html and not as content.

### Commands

[](#commands)

**format: {@...}**

```
{@include 'header.php'}

{@echo date('d-m-Y')}

{@if ($list):}
    # Note: you can use the curley brackets, so use the form foreach (...): endforeach instead
    {@foreach ($list as $k => $v):}
    data provided is : {$k} | {$v}
    {@endforeach}
{@endif}

# you can define the data in the template
{@ $d = date('d-m-Y')}

# and prints ...
date : {$d}

# Note: The statement in {@ ...} tags need not to be terminated with a semicolon ';'
{@ $list = [
    'black',
    'white'
]}

dump list:
# Note: The variable to dump, might as well be an object, array, bool int or a string
{$list}
```

Note: after {@ use the commands as if you were using the php code, though only constraint is that you can not use the loops or commands using the curly brackets.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

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

Recently: every ~187 days

Total

13

Last Release

1196d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed3b4bece580a28a0dd93c938b3336d8f73b80a3dda7f5e5881553a22dad83be?d=identicon)[Irfan TOOR](/maintainers/Irfan%20TOOR)

---

Top Contributors

[![irfantoor](https://avatars.githubusercontent.com/u/74845?v=4)](https://github.com/irfantoor "irfantoor (13 commits)")

---

Tags

phptemplateSimplefastenginesmartsmallsingle-file

### Embed Badge

![Health badge](/badges/irfantoor-template-engine/health.svg)

```
[![Health](https://phpackages.com/badges/irfantoor-template-engine/health.svg)](https://phpackages.com/packages/irfantoor-template-engine)
```

###  Alternatives

[monotek/minitpl

Miniature fully featured PHP template engine

125.5k1](/packages/monotek-minitpl)

PHPackages © 2026

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