19 Promising PHP Template Engines
PHP template engines are used widely to seperate the code & the layout.
This makes a website easier to maintain/update & creates a better development environment by enabling developers & designers to work together easier.
It sure has some drawbacks which is generally the performance (most libraries offer great solutions there) & need to learn a new syntax (not always).
To mention, using a template engine may not be suitable for every project. A website with few pages will probably won’t need it. But it can improve the development process of a portal, an e-commerce site or another web application easily.
Here are 19 PHP template engines with very nice features & have a continious development:
Smarty
The most popular PHP templating engine which prefers to call itself a "template/presentation framework" as it equips both the designer & programmers with powerful tools at the presentation layer.
It has a robust caching mechanism as well as a strong plug-in & add-on support.
With the template functions, debugging capabilities, security it provides & continious development, Smarty is a great engine.
Dwoo
Dwoo aims to be a serious alternative to Smarty with a cleaner codebase.
It has almost a totally compatible template & plugin system with Smarty.
Some main features are:
- Template Inheritance, a fresh look at complex template structures, now built without includes.
- Flexible plugin creation.
- Scope aware engine, allowing for shorter templates.
- Unicode / UTF-8 support for string manipulation functions & more..
Savant
A lightweight templating engine for PHP.
it uses PHP itself as its template language & no need to learn a new markup system.
Template Blocks
Template Blocks is a visual template engine, replacing any semantics of previous generation engines with an AJAX interface.
The engine is lightweight, flexible & extensible.
You can give any section with static content any extension of these popular extensions you like: .html, .htm or .php. They will all load up the same content!
Open Power Template
The new Open Power Template contains a built-in XML parser that fully understands the structure of your HTML code. It can find unclosed tags and perform complex operations on its structure.
For a better performance, every template is compiled into the PHP code, so that its execution is fast and can be speeded with the PHP accelerators. And results are cached.
TinyButStrong
A very easy to learn & implement templating system.
It is only 1 file, 1 PHP class with 6 methods & 5 properties.
Simplicity is its power. It can connect to any database, has a caching system & provides easy date-time and numeric formats.
Rain TPL
An easy to use and install engine which has 6 tags, 3 PHP functions and 2 PHP classes.
Rain TPL is WYSIWYG friendly, you can work with img/css relative paths & they are converted to the correct server path.
PHPTAL
PHPTAL is a PHP implementation of ZPT. To be short, PHPTAL is a XML/XHTML template library for PHP.
While most web developpers continue to use PHP tags as the core language of their templates, the Zope community came with a refreshing idea named TAL which is moving presentation actions inside XHTML attributes instead of using plain tags or elements.
PHP Template Engine
This PHP templating engine uses PHP, not a template scripting language.
It has a straightforward user authentication, session & cookie system. There is a built-in support for MySQL connections & your own classes/functions can be added with ease.
Template Lite
Template Lite, previously known as Smarty Light, is a drop in replacement for Smarty.
It supports most of the features of Smarty. Also, mentioned to be faster & consumes less memory compared to Smarty.
VTE – Vivvo Template Engine
VTE, originally built for Vivvo CMS but distributed for free, is light-weight, easy to use, yet powerful and scalable.
The template engine that can do recursions, object calls, arrays, but still remain within a single class in less than 1000 lines of code!
VTE language is XML-based and it consists of tags and attributes.
XTemplate
XTemplate allows you to store your HTML code separately from your PHP code.
It has many useful features yet code is short, highly optimized & used in various commercial & open source projects.
vlibTemplate
vlibTemplate is a class for templating PHP applications. It is normally included in the vlib package which has the following 3 classes:
- vlibTemplate
- vlibDate
- vlibMimeMail
Using this class you set the values for the variables, loops, if statements, etc. which are declared in the template. This enables you to separate all of the design from the data, which you create using PHP.
PHP-Sugar
It has a similar spirit with Smarty.
A flexible compilation engine that allows expressions similar to that of PHP itself is used. It also has a clean and easy to understand syntax.
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.
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
- nested blocks.
The template markup is really easy to learn & for high traffic enviroments a "memcached" cache extension exists.
Blitz templates
Blitz templates is a fast template engine written in C and compiled as a PHP module.
It started as a php_templates replacement, but developed into much more. It is based on extensible template controllers (PHP) and weakly-active templates (HTML).
Vemplator
With 220 lines of code, Vemplator offers:
- Conditionals: if/else and switch statements
- Dot-notation for class member variables (customer.name)
- Associative and numerical arrays (row[0] and rows[1]['name'])
- For-each looping over arrays (associative and numerically indexed)
- Includes (included templates are parsed and cached separately)
Template Engines Under PEAR

4 PEAR packages on templating:
QuickSkin
QuickSkin, previously known as SmartTemplate, works like a ‘template compiler’ that converts templates into executable PHP code and stores it for later reuse.
It 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)
What is your preference of PHP template engines & why?
Further Readings
- Tags:
Mysql Php
- Filed under: Design, Extras, Info, Other License, Software & Tools
- 47 Comments
Related Posts



































47 Responses for "19 Promising PHP Template Engines"
PHP is my favorite template engine
@Chris,
Expecting this comment, but not this fast
.
[...] Übersicht zu verschiedenen Templateengines für PHP findet sich eben auf WebResourcesDepot. Hier werden 19 Engines kurz vorgestellt und mit einem entsprechenden Link versehen, von Smarty [...]
Wow, no idea there was so many.
Yeah, you’re gonna get lots of ‘but PHP is already a templating engine’ comments, but I think Smarty is just swell
i think that CodeIgniter (http://codeigniter.com/) is also worth mentioning
@miko,
PHP frameworks are specifically not mentioned as they (most) come with their templating logic.
On the other hand, I totally agree it is worth mentioning – a great framework
.
@chris: me too. ob is a ice way for templating
Smarty is my favourite one. 10x for the list
Smarty sucks. Read on: http://lutt.se/blog/2006/08/13/why-template-engines-like-smarty-sucks-in-php.html
To the author(s), you very seriously need some grammar and spelling lessons.
What are the benefits of building a template engine on top of a template language? One thing is for sure separation of logic and markup is not achieved in any template engine I have used. Template engines add processing overhead whether they offer a caching mechanism or not.
Ditto.
Template engines are generally useless.
[...] 19 Promising PHP Template Engine. Comparte y [...]
Well good article. But IMHO, FastTemplate is the best template engine. No php code in the content. It definitely separates the logic from presentation. I’ve been using it since 2003, it works fine and I won’t stop using it.
I don’t think template engines is the best way to separate presentation logic from bussines logic, read my problems related to templates
http://codeassembly.com/Templates-and-presentation-logic/
I use TinyButStrong (TBS), simply because it’s the fastest engine on the list. Also the syntax is very clean.
Honestly if you’ve never tried it, then give it a go. It’s very extensible (cache plugins, page numbering plugins, etc)
very usefull info …
Smarty is great. I run our site on it in addition to many tools I develop for my day job.
For everyone saying “php is a template engine”. You are right it is. However, it is not nearly as easy and clean to escape in and out of PHP all day just to output some HTML.
Smarty makes this very easy and smooth.
Jeremy -> I would not say that a template engine that displays a list of 1000 elements in 0.05 s, whereas Smarty requires 0.005 s is the fastest one… Nothing has changed in TBS speed since I was doing a more serious template engine benchmark a couple of time ago.
The template engines are useful if they offer something more than “loops, conditions, expressions” in a non-PHP syntax. Complex websites require advanced solutions for code-reusing, portability, predefined patterns etc. PHP has at least the object oriented programming which does not look nice in this usage, but allows to achieve these goals somehow. And here, TinyButSlow offers very nice features like data sources or built-in support for displaying in columns in a clean syntax that beat Smarty and similar libraries. This part of TBS I really enjoy.
[...] desiderato, passandogli eventualmente dati e parametri necessari alla corretta visualizzazione. Qui potete trovare un elenco di soluzioni disponibili per [...]
All of our software are coded with Fast Template and the big advantage is that HTML designers not need to know any PHP code. All is HTML.
So we will keep this code up to date, I saw some people mentioned in the comment and they use it.
Open Power Template 2.0 is very promising. Templates are XML compatible so editors can validate templates and underscore any errors. With XML Schema, which is being produced at the moment, the XML editor will help you writing the code.
I don’t recommend Smarty or OPT v1. The syntax is ugly.
Hi,
you forgot the TPLN template engine
http://tpln.h2lsoft.com
smarty is my favorite! looking forward to version 3
I should probably try out a PHP template engine sometime. But, then again, doing everything from scratch is most of the fun.
I have authored h2o template, sorry for the self-promotion but this is quite interesting that people should checkout
a beautiful php template engine in django style.
http://github.com/speedmax/h2o-php/tree/master
Definitely Dwoo
I have been using Smarty for a long time, and switched to Dwoo 6 months ago.
I really like its “Smarty-like” syntax, which is clear, and eay to understand for web designers who don’t know PHP.
Most of all, Dwoo has a Zend Framework Adapter that works out-of-the-box.
If you already know PHP, then many template systems can make life more complicated. Mine is very simple – it has some basic template features, but allows generated elements of the page (like menus) to be run once and cached. All the coding is done in PHP rather than a template API.
More information…
http://www.optimalworks.net/blog/2007/software/free-download/tacs-php-template
I used to think that using a template engine in php would be useless. I have read a lot of articles that are against using a “template engine” and I myself have agreed to those articles without even trying out one. Learning another language or syntax just to separate the logic and presentation seems troublesome for me. Why would i still need to separate it when I am pretty comfortable without using a template engine? Then our company made it a requirement for all developers and designers to learn smarty. I had a lot of complaints in the first week or month of using it. Then after a while, I was getting used to it. I’ve been using smarty for more than a year now and i can really tell the difference when I was not using smarty. I find smarty very useful when redesigning or revising the logic of my code. It is easier for me to look for the part that I want to edit or the HTML elements that I want to change. There are a lot of good available plugins available too.
Wow very very well 3d
I like php template ,
but on the web only few people write
how to for it.
sorry for my bad english
Thx for your share,
See you
http://thietkexinh.com/TxTemplate/
Easy to use!
I recommend you to try ‘Template Underscore’.
It’s small, eazy and powerful.
compare with Smarty.
The best template engine ever is str_replace
If you just need a template engine, use PHP itself: http://thecodecentral.com/2009/06/28/a-simple-yet-powerful-php-template-engine.
Wow! Dint know there were this many. Most people only know smarty. Guess i’ll give one of the others a try. Thanks, cheers!
[...] You may not have realized that PHP is itself a templating engine. It allows you to intersperse logic and text, and has some handy features to make it easy. I’m going to show you how to build a php-based templating framework in one file. [...]
The main benefit of having a templating engine is that it essentially forces you to separate the presentation from the business logic, which makes it easy to say to someone “hey, you don’t know php, but you can edit this template” or to just mess with the way that the output looks without having to change any of your php code. So it’s fine to say “php is a templating engine already”, but the benefit of that strict separation of presentation and business logic is much harder to keep apart unless you use a different system for templates, or at least write your own process for keeping them apart.
QuickSkin is a great template engine. So is Smarty. For me those two are the best we have now.
I have create another simple and fast template engine, now is in beta but is quite stable.
Feel free to test and report bug or patch!
https://sourceforge.net/projects/myblock/
I use smarty for my site
cool,
Did’nt knew these many are available.
Must start using some to know it better.
Thanks,
BhaviK
This my Framework project suported tag style template engine
http://code.google.com/p/php-faces/
Twig hasn’t been mentioned, surely one of the most promising of all here, see these links why:
Why:
http://fabien.potencier.org/article/34/templating-engines-in-php
Twig’s home:
http://www.twig-project.org/
Like dbforch, I think that Twig is exactly as awesome as you’d expect !
For those of you who think PHP *is* the templating language, I agree with you. I love Django’s template inheritance though, and wish PHP had something like it. That is why I just released a new open source project. IT IS NOT A NEW TEMPLATE LANGUAGE, rather it is just a bunch of functions in PHP that utilize output buffers. the api is really clean. check it out:
http://phpti.com/
Great post, very helpful. I’ll be checking a lot of these out.
I’ve been using PHP-Sugar for many projects and its been a perfect fit.