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

  1. Reply Chris January 14, 2009 at 2:36 AM

    PHP is my favorite template engine 🙂

  2. Reply Umut M. January 14, 2009 at 2:39 AM


    Expecting this comment, but not this fast :).

  3. Reply Ian Jenkins January 14, 2009 at 6:05 AM

    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

  4. Reply miko January 14, 2009 at 7:16 AM

    i think that CodeIgniter (http://codeigniter.com/) is also worth mentioning

  5. Reply Umut M. January 14, 2009 at 7:45 AM


    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 :).

  6. Reply butters January 14, 2009 at 9:00 AM

    @chris: me too. ob is a ice way for templating 🙂

  7. Reply Tavy January 14, 2009 at 9:40 AM

    Smarty is my favourite one. 10x for the list

  8. Reply Steve Mulder January 14, 2009 at 1:28 PM

    To the author(s), you very seriously need some grammar and spelling lessons.

  9. Reply yaph January 14, 2009 at 3:06 PM

    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.

  10. Reply Shaun January 14, 2009 at 5:18 PM

    Template engines are generally useless.

  11. Reply Mardix January 15, 2009 at 1:35 AM

    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.

  12. Reply codeassembly January 15, 2009 at 3:39 AM

    I don’t think template engines is the best way to separate presentation logic from bussines logic, read my problems related to templates


  13. Reply Jeremy January 16, 2009 at 10:59 AM

    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)

  14. Reply ipoenk January 16, 2009 at 2:24 PM

    very usefull info …

  15. Reply AppBeacon January 16, 2009 at 6:12 PM

    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.

  16. Reply Zyx January 18, 2009 at 4:21 AM

    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.

  17. Reply Valics Lehel January 18, 2009 at 3:47 PM

    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.

  18. Reply Nowaker January 18, 2009 at 4:06 PM

    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.

  19. Reply Laurent H January 18, 2009 at 6:08 PM


    you forgot the TPLN template engine 😉

  20. Reply netzmeister January 19, 2009 at 5:19 AM

    smarty is my favorite! looking forward to version 3

  21. Reply Timothy January 19, 2009 at 1:17 PM

    I should probably try out a PHP template engine sometime. But, then again, doing everything from scratch is most of the fun.

  22. Reply Taylor luk January 19, 2009 at 7:24 PM

    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.


  23. Reply V0r_X January 20, 2009 at 3:59 AM

    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.

  24. Reply Craig February 1, 2009 at 1:30 PM

    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…

  25. Reply xcoiax February 23, 2009 at 3:32 AM

    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.

  26. Reply Slackye March 24, 2009 at 5:34 PM

    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

  27. Reply cafeda' May 3, 2009 at 12:01 PM
  28. Reply SangJin, Seong June 8, 2009 at 6:24 PM

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

  29. Reply nfo June 26, 2009 at 8:44 AM

    The best template engine ever is str_replace 😉

  30. Reply Deed July 1, 2009 at 2:45 PM

    If you just need a template engine, use PHP itself: http://thecodecentral.com/2009/06/28/a-simple-yet-powerful-php-template-engine.

  31. Reply Perry July 31, 2009 at 9:39 AM

    Wow! Dint know there were this many. Most people only know smarty. Guess i’ll give one of the others a try. Thanks, cheers!

  32. […] 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. […]

  33. Reply tchalvak August 28, 2009 at 12:19 PM

    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.

  34. Reply Andre Fernandes September 8, 2009 at 5:45 PM

    QuickSkin is a great template engine. So is Smarty. For me those two are the best we have now.

  35. Reply Angelo Bosio September 24, 2009 at 6:35 PM

    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!


  36. Reply free style September 24, 2009 at 10:45 PM

    I use smarty for my site

  37. Reply Patel BhaviK October 10, 2009 at 12:23 AM

    Did’nt knew these many are available.

    Must start using some to know it better.


  38. Reply Bora October 16, 2009 at 6:25 AM

    This my Framework project suported tag style template engine


  39. Reply dbforch October 20, 2009 at 7:15 AM

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


    Twig’s home:

  40. Reply Toskydao March 1, 2010 at 4:01 AM

    Like dbforch, I think that Twig is exactly as awesome as you’d expect !

  41. Reply Adam Shaw March 29, 2010 at 1:39 AM

    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:


  42. Reply Eric June 17, 2010 at 10:32 AM

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

  43. Reply Miles August 16, 2010 at 12:43 PM

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

  44. Reply anon September 23, 2010 at 2:07 PM

    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.

  45. Reply Eric September 28, 2010 at 4:39 PM

    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.

  46. Reply spletno programiranje November 26, 2010 at 7:23 AM

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

  47. Reply zanlok December 2, 2010 at 1:40 PM

    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.

  48. Reply spletne strani February 18, 2011 at 1:17 PM

    I vote for Smarty, as the name says it all, its smart to use it 🙂

  49. Reply Shakii February 19, 2011 at 1:54 PM

    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.

  50. Reply Stas February 24, 2011 at 3:53 AM

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

  51. Reply Pez March 8, 2011 at 12:19 PM

    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!

  52. Reply Michael M March 18, 2011 at 4:09 AM

    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.

  53. Reply Adam March 31, 2011 at 11:30 PM

    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

  54. Reply buurtnerd April 30, 2011 at 5:32 PM

    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.

  55. Reply Goran Bogdanovic May 22, 2011 at 8:53 AM

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

  56. Reply Umut M. May 22, 2011 at 10:07 AM


    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.

  57. Reply ji zhang June 4, 2011 at 3:45 PM

    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.

  58. Reply Romulus July 17, 2011 at 12:01 AM

    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.

  59. Reply Simon Schick September 2, 2011 at 9:33 AM

    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.

  60. Reply Jason Moore November 3, 2011 at 4:57 AM

    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.


  61. Reply xially November 30, 2011 at 9:23 AM

    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.

  62. Reply Han Chung December 29, 2011 at 10:47 PM

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

  63. Reply Cory Marsh January 10, 2012 at 12:39 AM

    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.

  64. Reply nine February 3, 2012 at 1:15 PM

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

    You can download it free from sourceforge


  65. Reply Matt February 17, 2012 at 5:32 PM

    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.

  66. Reply Matt February 17, 2012 at 5:33 PM

    So the comment system here butchers HTML in comments…

    Below ‘NOT logic’:

    Below ‘first example differing’:

  67. Reply Rafael Rodríguez March 28, 2012 at 3:44 PM

    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

  68. Reply Gabriel April 17, 2012 at 7:39 AM

    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.

  69. Reply Matt April 17, 2012 at 10:07 AM

    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:



  70. Reply Peter July 8, 2012 at 10:02 AM

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

  71. Reply Ruslan August 24, 2012 at 2:14 PM

    Another one to this list:

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


  72. Reply Andrew August 27, 2012 at 10:57 AM

    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.

  73. Reply Skander MABROUK August 31, 2012 at 8:05 PM

    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 !

  74. Reply Steve Reid December 28, 2012 at 12:47 PM

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

  75. Reply Zede February 17, 2013 at 2:37 AM

    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.

  76. Reply Amy Watson April 29, 2013 at 2:13 AM

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

Leave a reply