PHPackages                             davidphtee/templiphy - 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. davidphtee/templiphy

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

davidphtee/templiphy
====================

A simple PHP template engine with moustache syntax: {{ $variable }} and {{{ PHP code }}}.

01PHP

Since Jun 17Pushed 1y agoCompare

[ Source](https://github.com/davidphtee/TempliPHy)[ Packagist](https://packagist.org/packages/davidphtee/templiphy)[ RSS](/packages/davidphtee-templiphy/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

TempliPHy - a Simple PHP Template Engine
========================================

[](#templiphy---a-simple-php-template-engine)

A lightweight PHP template engine with moustache syntax for easy variable insertion and PHP code execution within your HTML templates.

---

Features
--------

[](#features)

✅ **Moustache Syntax**

- `{{ $variable }}` — Outputs a variable’s value
- `{{{ PHP code }}}` — Executes raw PHP code

✅ **Development &amp; Production Modes**

- Development mode uses a temporary file for better error tracing.
- Production mode uses `eval()` for faster rendering.

✅ **Safe Variable Handling**

- Variables are extracted safely.
- Errors are handled gracefully with meaningful messages.

---

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

[](#installation)

Simply include `Template.php` in your project.

```
require_once 'Template.php';
```

---

Usage
-----

[](#usage)

### 1️⃣ Create a Template instance

[](#1️⃣-create-a-template-instance)

```
$template = new Template(true); // `true` enables development mode
```

---

### 2️⃣ Set variables

[](#2️⃣-set-variables)

```
$template->set('title', 'Hello World');
$template->setArray([
    'name' => 'John',
    'age' => 30
]);
```

---

### 3️⃣ Create a template file

[](#3️⃣-create-a-template-file)

**example.tpl**

```
{{ $title }}
Name: {{ $name }}
Age: {{ $age }}

{{{ if($age >= 18): }}}
Access granted.
{{{ else: }}}
Access denied.
{{{ endif; }}}
```

---

### 4️⃣ Render the template

[](#4️⃣-render-the-template)

```
echo $template->fetch('example.tpl');
```

---

Configuration
-------------

[](#configuration)

ParameterDescription`isDevelopment``true` (default): uses a temporary file for detailed error tracing.
 `false`: uses `eval()` for faster rendering in production.---

Class Reference
---------------

[](#class-reference)

### `__construct(bool $isDevelopment = true)`

[](#__constructbool-isdevelopment--true)

Create a new instance.

- `true` → development mode
- `false` → production mode

### `set(string $name, mixed $value)`

[](#setstring-name-mixed-value)

Set a single variable.

### `setArray(array $list)`

[](#setarrayarray-list)

Set multiple variables at once.

### `fetch(string $file): string`

[](#fetchstring-file-string)

Render the given template file with the current variables.

---

Error Handling
--------------

[](#error-handling)

- Throws `RuntimeException` if:
    - The template file does not exist or is unreadable.
    - An error occurs while rendering the template.
- In development mode, the source file name and line numbers are preserved for easier debugging.

---

License
-------

[](#license)

MIT — use it freely!

---

Author
------

[](#author)

**David Tee**

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2fca3788b89ce7f71b439f71820e8693d1eb3a43b741015a8c773e06846f3367?d=identicon)[davidphtee](/maintainers/davidphtee)

---

Top Contributors

[![davidphtee](https://avatars.githubusercontent.com/u/22905624?v=4)](https://github.com/davidphtee "davidphtee (5 commits)")

### Embed Badge

![Health badge](/badges/davidphtee-templiphy/health.svg)

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

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3851.2M](/packages/limenius-react-bundle)[area17/laravel-auto-head-tags

Laravel Auto Head Tags helps you build the list of head elements for your app

4616.1k](/packages/area17-laravel-auto-head-tags)[ktquez/laravel-tinymce

TinyMCE editor for Laravel and Lumen Framework

2525.4k](/packages/ktquez-laravel-tinymce)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.3k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

282.2k](/packages/webkinder-sproutset)

PHPackages © 2026

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