When we think about PHP Template Engine, the most famous library is certainly Smarty. However, we may consider other alternatives to Smarty. In this post we have collected 16 template engines written in PHP that allow you to separate HTML code from PHP code.
Comparison Table
In the comparison table below, we have included:
- latest version (stable or beta) of library
- PHP version required
- size of zip package
- library extensibility
- documentation
- forum or group where users can ask for help
| Library | Version | PHP Version | Size | Extensible | Documentation | Forum |
|---|---|---|---|---|---|---|
| Smarty | 3.0.6 | 5 | 192kb | Yes | Yes | Yes |
| Savant | 3.0.1 | 5 | 20kb | No | Yes | Yes |
| PHPTAL | 1.2.2 | 5 | 319kb | No | Yes | Yes |
| TinyButStrong | 3.6.1 | 4/5 | 242kb | Yes | Yes | Yes |
| Yapter | 2.14b2 | 4/5 | 15kb | No | No | No |
| Dwoo | 1.1.1 | 5 | 107kb | No | Yes | Yes |
| QuickSkin | 5,0 | 4/5 | 263kb | Yes | Yes | No |
| Rain TPL | 2.4.9beta | 5 | 27kb | No | Yes | No |
| FXL Template | 2.1.1 | 5 | 15kb | No | Yes | No |
| Sugar | 0.83 | 5 | 51kb | No | Yes | Yes |
| Blitz Templates | 0.7.1.9 | 5 | 57kb | No | Yes | No |
| Template Blocks | 1.2 | 5 | 199kb | Yes | No | No |
| PHP XTemplate | 0.4 | 5 | 118kb | No | Yes | No |
| Vemplator | 0.6.1 | 5 | 9kb | No | Yes | No |
| Open Power Template | 2.0.6 | 5 | 1.30Mb | No | Yes | Yes |
| h2o | 0.4.1 | 5 | Yes | Yes | Yes | |
| TPLN | 3.5 | 5 | 631kb | Yes | Yes | Yes |
PHP Template Engines
Smarty

Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. This implies that PHP code is application logic, and is separated from the presentation.
The Smarty design was largely driven by these goals:
- clean separation of presentation from application code
- PHP backend, Smarty template frontend
- compliment PHP, not replace it
- fast development/deployment for programmers and designers
- quick and easy to maintain
- syntax easy to understand, no PHP knowledge required
- flexibility for custom development
- security: insulation from PHP
- free, open source

Link: http://www.smarty.net/
Savant

Savant is a powerful but lightweight object-oriented template system for PHP.
Unlike other template systems, Savant by default does not compile your templates into PHP; instead, it uses PHP itself as its template language so you don’t need to learn a new markup system.
Why Use Savant for Templates?
- You don’t need to learn a new language or markup to create a template. The template language is PHP, and the template file is a regular PHP file.
- You don’t have to worry about separate directories (or permissions on those directories) for compiled template sources, because Savant is not a compiling engine (the template scripts are already written in PHP).
- Even though Savant is not itself a compiling system, you can write your own compiler and plug it into Savant; this means you can use any template markup system you like.
- The Savant source code is easy to read, understand, and extend, because it is exceptionally well-commented.
- The object-oriented plugin, filter, error, and compiler classes for Savant are easy to use, understand, and extend.
- Because your template script is a regular PHP script, you can sprinkle it with comments and use phpDocumentor to document it.

Link: http://phpsavant.com/
PHPTAL

PHPTAL is a templating engine for PHP5 that implements brilliant Zope Page Templates syntax. PHPTAL is a PHP implementation of ZPT work. To be short, PHPTAL is a XML/XHTML template library for PHP.
While most web developpers continue to use ASP/JSP/PHP tags as the core language of their templates, the Zope community came with a refreshing idea named TAL. The idea was to move presentation actions inside XHTML attributes instead of using plain tags or elements.
Some PHPTAL advantages and features:
- enforces the separation between logic and presentation (the holy grail),
- warns you if you forget to close an HTML tag or have syntax errors in your template,
- no more
htmlentities(), - quite clean and readable templates,
- ability to insert sample text inside template to preview template result without PHP backend,
- integrates quite well with WYSIWYG HTML editors,
- data abstraction using XPath-like system,
- cool HTML macro system,
- integrated internationalization system (using
gettextor your own backend), - ability to replace XPath-like system with PHP expressions,
- nearly no speed loss (templates are compiled, expensive expressions can be replaced with plain PHP).
- compatible with PHP accelerators, which can improve performance even further,
- more than four years of ZPT community support (see zope website),
- extensible and easily hackable code,
- makes good use of PHP5 and SPL.

Link: http://phptal.org/
TinyButStrong
TinyButStrong is a library that enables you to dynamically create XML/HTML pages and any other files based on text source. It’s a Template Engine for the PHP language. It enables you to easily display information from your database, but also to seriously harmonize and simplify your PHP programming.
TinyButStrong is oriented to HTML but not specialized to Html. This means it can work as well with Text files, XML, RSS, RTF, WML, Excel (xml), … The OpenTBS plug-in enables your to merge OpenOffice and Ms Office documents.
Main features:
- can connect to any database type (in native: MySql, SQLite, PostgreSQL),
- easy date-time and numeric formats,
- blocks with alternated display,
- multi-columns display,
- conditional display,
- event functions,
- file inclusion and other scripts execution,
- cache system,
- plug-ins.

Link: http://www.tinybutstrong.com/
Yapter

Yapter (Yet Another PHP Template Engine (r)) is a simple, yet powerful template engine written completely in PHP, for PHP. Its purpose is to fully strip programming logic from the graphical aspects of creating websites in an elegant way.
Link: http://yapter.sourceforge.net/
Dwoo

Dwoo is a PHP5 template engine which is (almost) fully compatible with Smarty templates and plugins, but is written from scratch for PHP5, and adds many features.
Main features
- Template Inheritance, a fresh look at complex template structures, now built without includes
- Sub-template declaration within templates to allow recursive templates.
- Smarty syntax compatibility with several additions and shortcuts to speed up template writing
- Flexible plugin creation, plugins can be wrapped in classes or simple functions, they can be precompiled to optimize the load time of the template, etc.
- Scope aware engine, allowing for shorter templates
- Unicode / UTF-8 support for string manipulation functions.
- Generally faster than Smarty with variable speed improvements depending on the features used.
- E_STRICT compliant code that does not throw PHP warnings.
- Ready to use with several frameworks using the provided adapters (ZendFramework, Agavi, CakePHP, CodeIgniter)

Link: http://dwoo.org/
QuickSkin

QuickSkin is a Template Engine that was designed to support web based applications of any size. It is particularly suited to large scale applications like Content Management Systems. The project was originally started by Philipp v. Criegern and named “SmartTemplate”. The project was then taken over by Manuel ‘EndelWar’ Dalla Lana and HonestQiao. The name of the project back then led to confusion with Smarty Templating. Despite its advantages over other templating systems (speed, small footprint, ease of use, power), SmartTemplate has not been updated and had many outstanding bugs. Worx International Inc. has been using SmartTemplate on a variety of projects for several years. Over that time we have become very familiar with the code. We have now taken over the project. Our first task was to rename the project to make it less confusing, fix the bugs, and extend its capabilities — while maintaining its core simplicity and ease of use.
QuickSkin supports:
- Simple Scalar Substitution (Strings, etc.)
- Block Iterations (nested Arrays / BEGIN..END)
- Basic Control Structures (IF..ELSEIF..ELSE)
- Custom Extension (Output filters, uppercase, sprintf, etc.)
- Template Compilation (HTML templates are converted to executable PHP Code)
- Output Caching (Accelerates your applications by reusing page output)
- November 2007: QuickSkin is now PHP5 compliant and tested up to and including PHP 5.2.4. It is not tested with E_STRICT. One package to support both PHP4 and PHP5.

Link: http://quickskin.worxware.com/
Rain TPL

RainTPL is an open source PHP template engine, it load precompiled PHP templates:
- Easy, 8 Tags, 3 Methods, 1 Class in a single File
- Fast, load precompiled templates
- Useful, divide logic by design
- WYSIWYG, design HTML with img/css with relative paths, Rain will substitute with the correct paths

Link: http://www.raintpl.com/
FXL Template

FXL Template an easy to use template engine covering all the basic features of a template system. It supports simple text/array assignments, blocks and nested blocks. Well- used regular expressions and the simple markup are responsible for quick rendering. The template markup is really easy to learn – even for people not into programming. Everything can be done with just two types of place holders. For high traffic enviroments you are invited to test our “memcached” cache extension.

Link: http://www.feverxl.org/template/
Sugar
Sugar is a new template engine for PHP, similar in spirit to Smarty.
A powerful and flexible compilation engine is used which allows for powerful expressions similar to that of PHP itself. It also features a clean and easy to understand syntax, which was created with the average designer in mind.
Security is a strength of Sugar. For example, output is HTML-escaped by default, instead of requiring explicit escaping like PHP itself, which makes it far less likely to accidentally introduce an HTML or JavaScript code injection vulnerability from user-submitted content.
Link: http://php-sugar.net/
Blitz Templates

Blitz is a templating engine with two main features:
- Fast. Blitz is written in C and built as PHP-extension which makes it one of the fastest template engines (you may see the benchmarks section below)
- Clear. Blitz has quite simple and clear syntax and makes developer to build compact and easy-to-read-and-support code even for applications with very complex presentation logic

Link: http://alexeyrybak.com/blitz/new-docs-tmp/blitz_en.html
Template Blocks

Template Blocks is a visual template engine, replacing any semantics of previous generation engines with an AJAX interface.
It’s written in PHP and is distributed under the GPL.

Link: http://www.templateblocks.com/
PHP XTemplate
PHP XTemplate is a cool templating engine for PHP. XTemplate allows you to store your HTML code separately from your PHP code (as opposed to compiling your template into PHP as per Smarty etc.). It has many useful features such as nested blocks and various kinds of variable interpolation, and yet the code is very short and very optimized.

Link: http://www.phpxtemplate.org/
Vemplator

Vemplator is PHP template engine that strives to be light-weight yet featured, and does quite well in only 200 lines of code. The template syntax is concise, and the code is written to be extensible.

Link: http://www.greaterscope.net/projects/Vemplator
Open Power Template

Open Power Template is a template engine for PHP5. Its task is to produce a full HTML code from the script data and ”code templates” that show, how and where put them. OPT has many features not only for programmers, but also for template writers that make this process nice and easy.
Template syntax:
- Built-in XML parser that understands the HTML code structure and makes a real use of this.
- Scalable XML standard compliance – from the strict following the standards to the quirks mode ideal for processing non-XML documents.
- Modern and powerful template language that is something more that just a copy of control structures from PHP with modified syntax.
- Advanced support for declarative programming – tell, what you want to see, not how it is supposed to work.
- Imperative flow-control structures like loops and conditions.
- Sections – an advanced tool for constructing various types of lists, including tree rendering and displaying the data in columns.
- A set of tools for template modularization: inclusions and template inheritance (even dynamic).
- Blocks – easy-to-write instructions evaluated at runtime.
- Components – creating HTML forms with templates never was so easy.
- Smart HTML escaping and XSS filtering syntax techniques.
- Tools for code reuse – write once, use everywhere.
- Template portability – the same template code runs correctly in different places and with different data formats.
- Powerful expression engine with support for PHP objects.
- Large function set.
- Support for multilingual websites.
Link: http://www.invenzzia.org/en/projects/open-power-libraries/open-power-template
h20

H2o is template engine for PHP, there are a lot of the concept are inspired by projects like Django templates, Smarty and Jinja, implemented in a way that makes sense in PHP.
Some features:
- Readable and natural syntax.
- Reuse template inclusion and inheritance.
- Extensible through filters, tags and template extensions.
- Battery included – bundled rich set of filters and tags
- Internationalization
- Various caching support with multiple back-end

Link: http://www.h2o-template.org/
TPLN
TPLN is a fast php template engine.
The PHP code is separated of your design what facilitates the update of the design of your documents and to permit to separate work between webdesigner and PHP coder your work is built faster and it is easier to update !
Hot Features:
- Extremely easy to learn
- Open source project
- Powerful Plugin system (DB Pager, Captcha, Forms, Cache, Rss, Mail, Image)
- Database Abstraction layer via PDO (MySQL, Oracle, SQL Server…)
- Full Documentation, Friendly Community, …
Link: http://tpln.h2lsoft.com/















