19 Promising PHP Template Engines

PHP template engines are used widely to seperate the code & the layout.

PHP LogoThis 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 PHP Template Engine

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 PHP Template Engine

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 PHP Template Engine

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 PHP Template Engine

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

Open Power Template PHP

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.


Tiny But Strong PHP Template Engine

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

Rain PHP Template Engine

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 PHP Template Engine

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

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 - PHP Template Engine

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

Vivvo PHP 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 PHP Template Engine

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.


vlib PHP Template Engine

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 Template Engine

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 PHP Template Engine

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

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 PHP Template Engine

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

PHP PEAR Template Engine

4 PEAR packages on templating:


QuickSkin PHP Template Engine

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

  • PHP is my favorite template engine πŸ™‚

  • @Chris,

    Expecting this comment, but not this fast :).

  • 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

  • miko

    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

  • Steve Mulder

    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.

  • Shaun

    Template engines are generally useless.

  • 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


  • Jeremy

    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.

  • Zyx

    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.

  • 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 πŸ˜‰

  • 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.


  • V0r_X

    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…

  • xcoiax

    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.

  • Slackye

    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

  • cafeda’
  • I recommend you to try ‘Template Underscore’.
    It’s small, eazy and powerful.
    compare with Smarty.

  • nfo

    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.

  • Andre Fernandes

    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!


  • I use smarty for my site

  • Patel BhaviK

    Did’nt knew these many are available.

    Must start using some to know it better.


  • This my Framework project suported tag style template engine


  • dbforch

    Twig hasn’t been mentioned, surely one of the most promising of all here, see these links why:


    Twig’s home:

  • Toskydao

    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:


  • Great post, very helpful. I’ll be checking a lot of these out.

  • Miles

    I’ve been using PHP-Sugar for many projects and its been a perfect fit.

  • anon

    Good list. A very important concept of separating application code from presentation is also the separation of PHP from HTML/CSS. It just makes sense.

  • Eric

    Nice 3d,
    I agree that PHP is the best “template engine”,
    but web designer use HTML!
    Is been a while I’m using raintpl, it’s pretty easy and I can use template from http://www.themeforest.net, just adding few tags.

  • I dont know if a big site should use this kind of templating engines. It can really slow down the whole app.

  • zanlok

    Blitz is the bomb… VERY fast. And, it’s the “right” programming paradigm, where the controller has a dumb template for static text information, and you don’t have to worry about PHP processing or other nonsense.

  • I vote for Smarty, as the name says it all, its smart to use it πŸ™‚

  • I found an interesting php template engine comparison over here: http://www.phpcomparison.net/

    there’s also Twig and a new one Haanga, ugly name but promising too.

  • Stas

    I use Smarty in free PHP IDE Codelobster (http://www.codelobster.com) that has special plugin for it.

  • Pez

    I am currently the head dev of a basic template engine working from vemplator, it adds a lot more features, such as logic, for loops, if statements, accessing PHP functions and both PHP and HTML caching.

    See pegParse at http://labs.pegproductions.com/pegParse for more information and tell me what you think!

  • Michael M

    I have used the django template -checking the PHP h2o, Im at ease.

    Template Inheritance is a very valuable asset. In-fact I just dropped smarty for my projects in future.

  • I just fell in love with the Twig template engine.

    I really wanted template inheritance and tried Dwoo, h2o and a number of others… but sooner or later I found a problem I couldn’t solve without tons of time hacking the engine. I’m happy to say that I’ve solved all of these so far with Twig and haven’t found it’s limit yet.

    A MUST! Very close to Django: http://www.twig-project.org/

    Dwoo was initially very promising, but is severely limited in how it implements blocks and inheritance. You can NOT nest blocks or define new blocks in children see http://forum.dwoo.org/viewtopic.php?id=173

  • Wonderful list of engines. I have used Smarty and Savant in the past as well as inline PHP.

    Here is another template engine, it allows one to write 100% clean html code, without any code. Thus achieving full separation between markup and logic.


    It works by using marker tags that capture areas inside the template. Maybe worth looking at.

  • What is problem putting new template engine here. I post TIDEngine and you delete post. If there are problems just contact ne on same address..

  • @Goran,

    The post focuses on “totally free” template engines. As far as I can see, TIDEngine is not free for commercial projects.

    There are many comments being posted for commercial projects which can make this spot more an adspace than comments if they are approved.

    Simply, there are no problems but this post discusses free solutions and I’m just trying to keep it so.

  • ji zhang

    Dwoo , there is not much activities,
    Open Power Template, seems another one,

    btw, good job and thanks to the author. Never notice this much templated egnine.

  • Romulus

    Cleanest template engine I’ve seen is in the Fat-Free framework. Looks like abbreviated PHP. And it’s really fast because it can use APC or XCache at the backend.

  • Even if there are many template-engines listed in here …

    FLUID is missing πŸ™‚
    It’s used in the new Framework FLOW3 that’s currently in development.
    The new TYPO3-version 5.0 will be build on this framework.

  • Jason Moore

    I’ve used smarty but when I needed something else like no php in the template code, the choice become different. So I tested few systems and now I use MoxesTemplate.


  • Also you can look what is the difference in perfomance between Twig and Smarty
    I think the perfomance is also very important thing which has to be considered when you deciding to use this template engine or not.

  • I have created an online twig template editor at http://demo.codefunc.com if anyone is interested in testing out twig.

  • Great list! Thanks for compiling this!

    one more:
    Apache Wicket like template system for PHP – BSD license. https://sourceforge.net/projects/psaghetti/
    fully compliant xhtml markup (no {} tags)

    supports conditionals, loops, nested loops, language files support and variable modifiers. Compiles down to vsprintf() calls and eliminates the context switching in compiled views. >20% faster than smarty rendering. Most views compile once in <30ms. Worth a look.

  • Our new tag based template engine for php. Small, Fast and easy to learn.

    You can download it free from sourceforge


  • Matt

    I can’t believe the scores of people that don’t really comprehend what ‘logic’ is.
    This is NOT logic mixed with presentation:

    This IS logic mixed with presentation:
    $results = $this->db->getUsers($_POST[‘group’]);
    while ($row = $results->next()) {
    // do something to rows
    foreach ($newRows) {
    // output rows

    See the difference?

    Now how does the first example differ from this (semantically) (hint: it doesn’t):

    Anyone arguing that they don’t want PHP in a template because they don’t want logic in their template is misinformed about what logic is. Using control structures during output also does not constitute business logic in a template (if, while, etc); again, most template engines provide some abstraction for that, so it’s no different from using PHP itself. Remember, every templating engine is built on PHP itself… ergo, what you want to do can be accomplished with straight PHP as well.

  • Matt

    So the comment system here butchers HTML in comments…

    Below ‘NOT logic’:

    Below ‘first example differing’:

  • I am the author of Div PHP Template Engine. Div is a template engine for PHP that allows the separation of labor between the programmer and designer. As the designer built templates with some specific brands, the programmer uses the template to replace these marks with the data, information or values ​​that apply.

    You can download it free from


    Try it

  • And then, yet another Template Engine: FigDice

    It is very different in nature, from all the other systems here: it REALLY lets you, Web Author, make REAL HTML files.
    And it lets you, Developer, use these real files without having to maintain an intermediary document.

    Very fast, easy to learn, fun to play with.
    Worthes a try.

  • Matt

    Another one missing from that list is mTemplate: http://code.google.com/p/mtemplate/

    Its a simple PHP template engine with a built-in caching mechanism.

    I find it to be most similar to RainTPL, although if I remember correctly, RainTPL couldn’t cache content?

    What I like about mTemplate is its “Sections” concept. It allows you to subdivide your template files into smaller pieces, which enables you to keep your loops and conditional statements in your PHP code without messing up your template files with weird syntax like:



  • Peter

    RainTPL have an cache method for content since a while.
    You can read about how to use under “Documentation for PHP developers”:

  • Another one to this list:

    Histone is an open source template engine for Java, JavaScript and PHP.


  • The KudzuPHP template engine is built differently. In KudzuPHP your web page invokes the template engine which then makes callbacks into the hosting php when and where required. In most cases you can change the layout of the page by changing the template without changing the logic of the hosting php.

    It has a nice component library system built in that allows you to import libraries from either code or the template.

    With KudzuPHP you can write php that contains zero html markup.

    The Kazoo plugin for WordPress uses it to allow you to access the WordPress API with inline templates within your WordPress content or templates stored within the WordPress database.

  • Where is Twig ?? currently, it the most faster and easier to use. After making a suite of benchmark on PHP templates engines, twig comes in the second place just after native php language !

  • Steve Reid

    I use Smarty and it’s good enough for my purposes, however I will investigate some of these other template engines.

  • Zede

    That Savant thing is not a template engine.

    It’s just one file including others and a convention that the included files use only variables computed in the first file.

    That does not make a template engine.

  • The template engines are quite wonderful. But I would like to ask which works for CodeIgniter Framework Application development?