PHPackages                             iassasin/phplate - 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. iassasin/phplate

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

iassasin/phplate
================

Lightweight template engine for PHP

v2.3.0(6y ago)3741[4 issues](https://github.com/iassasin/phplate/issues)MITPHPPHP &gt;=7.0CI failing

Since Aug 9Pushed 6y ago2 watchersCompare

[ Source](https://github.com/iassasin/phplate)[ Packagist](https://packagist.org/packages/iassasin/phplate)[ Docs](https://github.com/iassasin/phplate)[ RSS](/packages/iassasin-phplate/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (5)Dependencies (2)Versions (9)Used By (0)

Phplate
=======

[](#phplate)

[![PHP Version](https://camo.githubusercontent.com/5c3072425e67297c8ef63d17acd2c86a0d2ef324f19249f2280bd7de902f63a2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230372e302d3838393242462e737667)](https://php.net/)[![Build Status](https://camo.githubusercontent.com/0110de08b174c14156b0b3b2220f54a29b27b6c04426e259a8d216581033e579/68747470733a2f2f7472617669732d63692e6f72672f696173736173696e2f7068706c6174652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/iassasin/phplate)[![Coverage Status](https://camo.githubusercontent.com/a1719ca9dc79274deccbe13f6e4947ff2a45a65574f057ddceb627cec3ed7de9/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f696173736173696e2f7068706c6174652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/iassasin/phplate?branch=master)

Phplate - это легковесный и функциональный препроцессор шаблонов, написанный на php и не требующий никаких зависимостей.

Быстрый старт
=============

[](#быстрый-старт)

Чтобы начать использовать phplate, нужно установить его, как composer-пакет (либо вручную сделать `require_once` для всех файлов из каталога `src/`), после чего создать свой php-файл с настройками, например:

```
require_once 'vendor/autoload.php';
use Iassasin\Phplate\Template;

// Настройка пути к каталогу с шаблонами
Template::init($_SERVER['DOCUMENT_ROOT'].'/resources/templates/');
```

Полный список настроек вы можете найти в [документации](docs/api.md).

Используя статический метод `Template::build`, производится подстановка аргументов шаблона в шаблон. Результатом является строка, которую можно отдать клиенту.
Аргументы передаются шаблону с помощью массива любого уровня вложенности.

Конечно же, возможности phplate не ограничиваются только подстановкой переменных в указанные места, но также есть возможность условного вывода ([if](docs/constructions/if.md)), написания циклов ([for](docs/constructions/for.md)), вычисления выражений перед выводом (в частности, препроцессинг параметров с помощью [пайп-функций](docs/pipe-functions.md)), вынос повторяющегося кода в [виджеты](docs/constructions/widget.md) и другие возможности.

Пример использования
--------------------

[](#пример-использования)

Допустим, файлы шаблонов хранятся в каталоге `%site_root%/resources/templates/`, а phplate сконфигурирован, как в примере выше.
Шаблон, файл `%site_root%/resources/templates/order.html`:

```
Здравствуйте, {{name}}!
Ваш заказ №{{order.id}} поступил в пункт выдачи по адресу {{order.address}}.

```

Использование шаблона, файл `%site_root%/index.php`:

```
require_once 'phplate_config.php'; // созданный нами выше файл конфига

echo Template::build('order', [
	'name' => 'Петя',
	'order' => [
		'id' => 489,
		'address' => 'ул. Шаблонная, д.1, кв. 1',
	],
]);
```

В результате, когда произойдет переход на главную страницу сайта, пользователь увидит:

```
Здравствуйте, Петя!
Ваш заказ №489 поступил в пункт выдачи по адресу ул. Шаблонная, д.1, кв. 1.

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 69.3% 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 ~143 days

Recently: every ~191 days

Total

7

Last Release

2343d ago

Major Versions

v1.6.0 → v2.0.02017-11-09

PHP version history (2 changes)v1.6.0PHP &gt;=5.6

v2.0.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/55b921aba1206775e55bae7950fee7e6a62271203663e9b4b63ad48c707bbfe1?d=identicon)[iassasin](/maintainers/iassasin)

---

Top Contributors

[![iassasin](https://avatars.githubusercontent.com/u/20709774?v=4)](https://github.com/iassasin "iassasin (124 commits)")[![maestroprog](https://avatars.githubusercontent.com/u/13558383?v=4)](https://github.com/maestroprog "maestroprog (55 commits)")

---

Tags

composerphpphp7templatetemplate-enginetemplatestemplatepreprocessor

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/iassasin-phplate/health.svg)

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

###  Alternatives

[phpoffice/phpword

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

7.5k34.7M186](/packages/phpoffice-phpword)[rize/uri-template

PHP URI Template (RFC 6570) supports both expansion &amp; extraction

420137.3M46](/packages/rize-uri-template)[mopa/bootstrap-sandbox-bundle

Seperate live docs from code

256.8k](/packages/mopa-bootstrap-sandbox-bundle)[larablocks/pigeon

A more flexible email message builder for Laravel 5 including chained methods, reusable message configurations, and message layout and template view management.

143.7k](/packages/larablocks-pigeon)

PHPackages © 2026

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