titpetric/minitpl

Miniature fully featured PHP template engine

Maintainers

Package info

github.com/titpetric/minitpl

pkg:composer/titpetric/minitpl

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 12

Open Issues: 0

v1.2.0 2026-08-17 13:34 UTC

This package is auto-updated.

Last update: 2026-08-17 16:58:28 UTC


README

The goal of the MiniTPL template engine is to provide a miniature framework which allows you to rapidly create and consume Smarty-like templates without adding the overhead of Smarty to your choice of a PHP framework.

In benchmarks the speed of Mini TPL is very close to PHP itself. All that is usually needed for Mini TPL is a 3KB PHP code overhead. So it beats Smarty, and usual PHP vsprintf and str_replace functionality.

With a total size of about 13KB and the functionality contained, this is one of the smallest full featured template engines for PHP to date.

MiniTPL is available on packagist as titpetric/minitpl.

To start using MiniTPL in your project with composer, create a composer.json file:

{
    "require": {
        "titpetric/minitpl": ">=1.0"
    }
}

And run composer install. You can start using MiniTPL right away.

<?php

include("vendor/autoload.php");

$tpl = new MiniTPL\Template;

$tpl->load("test.tpl");
$tpl->render();

The classes live in the MiniTPL namespace: MiniTPL\Template, MiniTPL\Compiler and MiniTPL\Hook. Compiler and Hook are usable stand-alone; Template is the entrypoint you normally want.

phpscript

The engine is kept compatible with phpscript, a PHP interpreter written in Go. phpscript resolves composer.json and the vendor/ directory on its own, so the same vendor/autoload.php include works there:

phpscript example.php

Testing

The project tries to maintain 100% code coverage. You can verify this by running phpunit --coverage-text, or uncommenting the logging section within phpunit.xml.