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

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

codesaur/template
=================

Энгийн текст-суурьтай темплейтээс эхлээд Twig-ээр бичсэн хүчирхэг темплейт хүртэл дэмждэг минимал, өргөтгөх боломжтой PHP template engine

v3.0.1(2mo ago)1463↓50%1MITPHPPHP ^8.2.1CI passing

Since Mar 9Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/codesaur-php/Template)[ Packagist](https://packagist.org/packages/codesaur/template)[ Docs](https://github.com/codesaur-php)[ RSS](/packages/codesaur-template/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (4)Versions (36)Used By (1)

codesaur/template
=================

[](#codesaurtemplate)

[![CI](https://github.com/codesaur-php/Template/actions/workflows/ci.yml/badge.svg)](https://github.com/codesaur-php/Template/actions/workflows/ci.yml)[![PHP Version](https://camo.githubusercontent.com/1015683ef28e870620edc19b6e22b456c0dc170c260fa4645905e93438f607a6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e322e312d3737374242342e7376673f6c6f676f3d706870)](https://www.php.net/)[![License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)

Агуулга / Table of Contents
---------------------------

[](#агуулга--table-of-contents)

1. [Монгол](#1-%D0%BC%D0%BE%D0%BD%D0%B3%D0%BE%D0%BB-%D1%82%D0%B0%D0%B9%D0%BB%D0%B1%D0%B0%D1%80) | 2. [English](#2-english-description) | 3. [Getting Started](#3-getting-started)

---

1. Монгол тайлбар
-----------------

[](#1-монгол-тайлбар)

Бие даасан PHP template engine. Хөгжлийн явцад Twig template engine-ийн синтакс, дизайн загвараас санаа авч чадамжуудаа өргөжүүлсэн.

`codesaur/template` нь **codesaur ecosystem**-ийн нэг хэсэг бөгөөд энгийн текст-суурьтай темплейтээс эхлээд if/for/macro/filter бүхий хүчирхэг темплейт хүртэл дэмждэг минимал PHP template engine юм.

Багц нь дараах 2 үндсэн class-аас бүрдэнэ:

- **MemoryTemplate** - бүрэн template engine (if, for, filter, function, macro, expression parser)
- **FileTemplate** - файлын системээс template уншиж рэндэрлэх (MemoryTemplate-ийг өргөтгөнө)

### Дэлгэрэнгүй мэдээлэл

[](#дэлгэрэнгүй-мэдээлэл)

- [Бүрэн танилцуулга](docs/mn/README.md) - Суурилуулалт, хэрэглээ, жишээнүүд
- [API тайлбар](docs/mn/api.md) - Бүх метод, exception-уудийн тайлбар
- [Шалгалтын тайлан](docs/mn/review.md) - Код шалгалтын тайлан

---

2. English description
----------------------

[](#2-english-description)

A self-contained PHP template engine. During its evolution, adopted syntax and design patterns inspired by Twig.

`codesaur/template` is part of the **codesaur ecosystem** - a minimal PHP template engine supporting everything from simple text placeholders to powerful templates with if/for/macro/filter syntax.

The package consists of 2 core classes:

- **MemoryTemplate** - full template engine (if, for, filter, function, macro, expression parser)
- **FileTemplate** - file-based template loader (extends MemoryTemplate)

### Documentation

[](#documentation)

- [Full Documentation](docs/en/README.md) - Installation, usage, examples
- [API Reference](docs/en/api.md) - Complete API documentation
- [Review](docs/en/review.md) - Code review report

---

3. Getting Started
------------------

[](#3-getting-started)

### Requirements

[](#requirements)

- PHP **8.2.1+** (json, mbstring extensions)
- Composer

### Installation

[](#installation)

Composer ашиглан суулгана / Install via Composer:

```
composer require codesaur/template
```

### Quick Example

[](#quick-example)

```
use codesaur\Template\MemoryTemplate;

// Бүрэн engine - if, for, filter, function бүгд дэмжинэ
$page = new MemoryTemplate(
    '{% for item in items %}{{ item|upper }}{% endfor %}',
    ['items' => ['a', 'b', 'c']]
);
echo $page;
```

```
use codesaur\Template\FileTemplate;

// Файл суурьтай template
$page = new FileTemplate('page.html', [
    'title' => 'Hello',
    'items' => ['a', 'b', 'c']
]);
$page->addFunction('link', fn($route) => "/app/$route");
echo $page;
```

```

{{ title }}
Home

{% for item in items %}
    {{ item }}
{% endfor %}

```

### Running Tests

[](#running-tests)

Тест ажиллуулах / Run tests:

```
composer test
```

---

Changelog
---------

[](#changelog)

- [CHANGELOG.md](CHANGELOG.md) - Full version history

Contributing &amp; Security
---------------------------

[](#contributing--security)

- [Contributing Guide](.github/CONTRIBUTING.md)
- [Security Policy](.github/SECURITY.md)

License
-------

[](#license)

This project is licensed under the MIT License.

Author
------

[](#author)

**Narankhuu**

**codesaur Ecosystem:**

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance88

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity77

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

Recently: every ~24 days

Total

35

Last Release

74d ago

Major Versions

v1.6.0 → v2.0.02025-11-28

v2.2.0 → v3.0.02026-01-08

PHP version history (3 changes)v1.0PHP &gt;=7.2.0

v2.0.1PHP &gt;=8.2.1

v3.0.0PHP ^8.2.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/2281c1b7b23007da57ad0526923a5f822dea64629ab1cb70749188d2b869e55c?d=identicon)[codesaur](/maintainers/codesaur)

---

Top Contributors

[![codesaur](https://avatars.githubusercontent.com/u/4127594?v=4)](https://github.com/codesaur "codesaur (71 commits)")

---

Tags

htmltemplatecodesaurmongolmongolianarankhuucodenкодзаврнаранхүүкоден

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[phpoffice/phpword

PHPWord - A pure PHP library for reading and writing word processing documents (OOXML, ODF, RTF, HTML, PDF)

7.6k34.7M186](/packages/phpoffice-phpword)[latte/latte

☕ Latte: the intuitive and fast template engine for those who want the most secure PHP sites. Introduces context-sensitive escaping.

1.3k15.7M683](/packages/latte-latte)[twig/string-extra

A Twig extension for Symfony String

22046.0M133](/packages/twig-string-extra)[twig/markdown-extra

A Twig extension for Markdown

12114.3M83](/packages/twig-markdown-extra)[twig/html-extra

A Twig extension for HTML

787.6M41](/packages/twig-html-extra)[twig/cache-extra

A Twig extension for Symfony Cache

392.1M20](/packages/twig-cache-extra)

PHPackages © 2026

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