Jaslabs: High performance Software

High Performance Software

Top 25 PHP template engines

By Justin Silverton

After searching the Internet for a good template engine, I have compiled the following list:

Smarty
Smarty is a template engine that compiles the templates into PHP scripts, then executes those scripts. Very fast, very flexible.

Heyes Template Class
A very easy to use, yet powerful and quick template engine that enables you to separate your page layout and design from your code.

FastTemplate
A simple variable interpolation template class that parses your templates for variables and spits out HTML with their values

ShellPage
A simple and easy to use class that lets you make whole websites based on template files for layouts. Change the template and your whole site changes.

STP Simple Template Parser
A simple, light weight and easy to use template parser class. It can assemble a page from several templates, output result pages to the browser or write them to the filesystem.

OO Template Class
An object oriented template class you can use in your own programs.

SimpleTemplate
A template engine to create and structure websites and applications. It can translate and compile the templates.

bTemplate
A small and fast template class that allows you to separate your PHP logic from your HTML presentation code.

Savant
A powerful but lightweight PEAR-compliant template system. It is non-compiling, and uses PHP itself as its template language.

ETS - easy template system
A template system that allows you to reshuffle templates with exactly the same data.

EasyTemplatePHP
A simple, yet powerful templating system for your site.

vlibTemplate
A fast, full featured template system that includes a caching and debugging class.

AvanTemplate
A template engine that is multi-byte safe and consumes little computing resource. It supports variable replacement and content blocks that can be set to hidden or shown.

Grafx Software’s Fast Template
A modification of the popular Fast Template system, this includes a cache function, debug console, and silent removal of unassigned dynamic blocks.

TemplatePower
A fast, simple and powerful template class. Features nested dynamic block support, block/file include support and show/hide unassigned variables.

TagTemplate
This library function was designed for use with template files and allows you to retrieve info from HTML files.

htmltmpl: templating engine
A templating engine for Python and PHP. Targeted to web application developers, who want to separate program code and design of their projects.

PHP Class for Parsing Dreamweaver templates
A simple class to parse a Dreamweaver template for use in custom mods for a Gallery 2 and a WordPress blog.

MiniTemplator (Template Engine)
A compact template engine for HTML files. It features a simple syntax for template variables and blocks. Blocks can be nested.

Layout Solution
Simplifies website development and maintenance. It holds commonly used variables and page elements so you don’t need to duplicate common layouts over and over.

Cached Fast Template
This inclusion into FastTemplate allows for caching of the template files, and can even cache with different specifications on separate blocks of content.

TinyButStrong
A template engine that supports MySQL, Odbc, Sql-Server and ADODB. It includes seven methods and two properties.

Brian Lozier’s php based template engine
Only 2k in size, very fast and object-orientated.

WACT
a template engine that separates code from design.

PHPTAL
a XML/XHTML template library for PHP.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • DZone
  • Slashdot
  • StumbleUpon
  • Technorati

74 Comments so far

  1. Anonymous March 16th, 2006 10:37 am

    Nice, Thanks!

  2. judas_iscariote April 13th, 2006 2:19 am

    You are missing IMHO one the best disigned one “PHPTAL”.

    In fact I have done the same research of you and picked PHPTAL as one of the very first places.

    PHPTAL ( compiled )
    Smarty
    HTML_Template_it ( not compiled )

    are my choices.

  3. justin silverton April 13th, 2006 7:30 pm

    thanks for the suggestion. I didn’t even know about that templatate engine. I try it out.

  4. Michael July 24th, 2006 9:15 am

    Please add PEARs HTML_Template_IT. I use it for all my projects and find it very good. You should give it a try…

  5. Marcin July 31st, 2006 12:41 pm

    You cann add to this list web.template - https://sourceforge.net/projects/webtemplate/. Now I working at docummentation, but you can get same examples from sourceforge.net. I add to this template new way to get values form PHP;-)

  6. Greg Donald August 1st, 2006 11:41 am

    All you need is eval(). Anything else is baggage.

    Smarty.. pffft.

  7. EndelWar August 1st, 2006 12:13 pm

    Thanks for your list!
    It misses smarttemplate engine (http://smarttemplate.sf.net)

  8. pcdinh August 1st, 2006 12:17 pm

    I think Savant http://phpsavant.com/ is the best. Solar http://solarphp.com and Savant is a great companion for every PHP professional developers.

    Smarty is very slow and too fat. It should work for anybody who doesnt want to consider PHP a templating language. When using Smarty, you will see that your application will be slower, more memory footprint, less scalable. If you want to separate PHP Code from Presentation, use Smarty and try to learn once more Smarty language. If you want to separate Business Logic from Presention, use Savant for faster, less memory footprint and more scalable applications.

    Besides, I can mention PHPTal. It is better designed than Smarty but you will need to learn once more language as well. I dont know the others because they have low profile.

    Be brief, the first and the best, Savant: http://phpsavant.com/
    The second, PHPTal: http://phptal.motion-twin.com/
    The third, Smarty

    Just my 2 cents

  9. Joomla User August 1st, 2006 12:28 pm
  10. sarman August 1st, 2006 12:45 pm

    Don’t forget about FASTEST php templates engine

    php-templates

    http://sourceforge.net/projects/php-templates/

    it’s build as extension into php, my favorite.

  11. Matthew R. Miller August 1st, 2006 1:02 pm

    I have always used Savant, which is a non compiled template engine, but very useful.

  12. Angry August 1st, 2006 1:12 pm

    Have you looked at the template engines that various bigger CMS’s use, such as the drupal PHPTemplate or xEngine, or whatever the Mambo equiv is?

  13. nm August 1st, 2006 2:03 pm

    missing pattemplate (http://www.php-tool.de). Much easier to work with than smarty and very powerful.

  14. Tison August 1st, 2006 2:51 pm

    Definitely worth looking into. If anyone is interested in combining powerful libraries, Cameron Olthuis has a great compilation of the top ten javascript libraries…
    http://www.cameronolthuis.com/2006/06/top-10-web-developer-libraries/

    also - check out jsquery.com for another great library.

  15. Jeff Bailey August 1st, 2006 2:51 pm

    I used to use Smarty but have opted to simply separate the logic from the presentation and use php as the template language. There are some advantages to using template engines but IMHO the speed and simplicity of plain PHP can’t be beat.

  16. Tison August 1st, 2006 2:54 pm

    I’m sorry that’s http://jquery.com

  17. sam August 1st, 2006 3:08 pm

    You also forgot about patTemplate from php-tools. Not as evolved as Smarty, but nice and powerfull for a small and limited use.

  18. Darryl August 1st, 2006 3:30 pm

    People, this list says Top 25, not “a list of PHP template engines”.

  19. John Regier August 1st, 2006 3:59 pm

    Xaraya’s blocklayout is a great engine - too bad it’s too tightly coupled to the rest of the framework… :-/

  20. Ivan Minic August 1st, 2006 4:03 pm

    phpsavant.com missing

  21. Siggy Ross August 1st, 2006 4:55 pm

    what about HTML::Template by Sammy boy. It’s da bomb you!

  22. Michel Bottan August 1st, 2006 5:15 pm

    PHPTAL implements the attribute language from ZOPE.

    It’s far the easiest way to build template, with an approach that doesn’t affect webdesigners works.

    I did a benchmark with FastTemplate and PHPTAL using JMeter. I developed two templates according, having the same funcionality for both engines, check blocks, assign values, etc… and was suprised with the results, PHPTAL delivered templates faster then FastTemplate.

    Now, i will do the same test in my local network to avoid any interference.

  23. Marios August 1st, 2006 5:37 pm

    How about template-lite? (used to be called smarty-lite). I find it very versatile and quick…

    http://templatelite.sourceforge.net/

  24. philip August 1st, 2006 9:40 pm

    Do any of them work with CakePHP?

  25. pointman August 1st, 2006 9:59 pm
  26. Flexy August 1st, 2006 10:37 pm

    What about Flexy, mmm duh.

  27. varun August 2nd, 2006 1:15 am

    super cool list…

    i think even flickr from yahoo is using smarty only..

  28. Fansjo Leihitu August 2nd, 2006 4:47 am

    Well .. I use XTemplate (www.phpxtemplate.org/). for me , I don’t like Smarty. It has way to much options/features. I like the KISS method ;-) , and that’s what XTemplate does for me ;-)

  29. Qube August 2nd, 2006 8:48 am

    Alright, yeah got a new one, it’s pretty new, at least to the opensource arena, but I’ve used it on and off for well, probably a couple years now. It’s recently undergone some major changes, so flexibility is something it definitely has.

    http://code.divineaspirations.net/chip/index.html

    Take a peak, try it out, see if it does what you need to. I’ve yet to find a task it can’t handle with simplicity.

  30. Philou August 2nd, 2006 12:47 pm

    I agree with Greg Donald. Why Lord why learn yet another template language when you already know one : PHP ? All you need is restraining to simple commands (print, if/then/else, foreach) in template files and a smart use of eval()/ob_xxx functions in your template engine.

    Everything else IMHO is a waste of time/CPU/disk space/neurons/baggage(?), and Smarty’s not so smart.

  31. justin August 2nd, 2006 1:15 pm

    I use templates not to make my web apps run faster (although many do have the ability to cache ouput), but to separate the code from the design. This allows me to do all the back-end programming (through straight PHP) and have a designer change around the template files (Many Designers don’t know anything about PHP).

    It also make larger projects easier to maintain (if you have to make a security update in your php files and someone has already customized the design, it’s not going to be a quick fix. The code will have to be manually changed).

    Take a look at Oscommerce sometime and you will see why templates are a good idea.

  32. Philou August 2nd, 2006 2:51 pm

    Templates are not only a good idea, they are necessary :) . But this separation logic/data/presentation can be achieved by using templates written in PHP, without having to learn a new language that basically mimics the possibilities of PHP.

  33. David Caunt August 2nd, 2006 5:08 pm

    http://www.phpxtemplate.org/ is the home of PHP XTemplate - another great template engine.

    If you are looking for a templating engine with recursion, repeating regions and file includes, without the BAGGAGE of Smarty, take a look.

  34. vnjug August 8th, 2006 12:12 am

    Savant is better. http://www.phpsavant.com

  35. Max August 10th, 2006 2:54 am

    I agree with what you said.

  36. Olivier Loynet August 10th, 2006 3:30 am

    A fabulous extension for TinyButTrong is the ability to make OpenOffice document like you generate HTML pages.

    Have a look :
    http://www.tinybutstrong.com/tbsooo.php

    Also the new version of TinyButTrong is 3.0.

    The major change in TBS version 3.0 is the Plug-ins feature. Plug-ins enable you to customize some TBS processes such as LoadTemplate(), Show(), MergeBlock(), Special Var fields and string conversion. You can also add you own command to a plug-in. This is also the occasion for TBS to leave some deprecated features and to rearrange incoherent way of work. Thus, some old features will be converted into TBS plug-ins.

    http://www.tinybutstrong.com/support/tbs_v3_whatsnew.htm

    There are plugins for, by example, to make Excel 2007 document.
    http://www.tinybutstrong.com/plugins.php

  37. aspirin August 17th, 2006 3:49 pm

    Smarty - the best :)

  38. Christopher August 28th, 2006 1:02 pm

    How about PHPLIB?

    http://sourceforge.net/projects/phplib

    Supposedly faster than Fast Template. Around since 1999

  39. Top 25 PHP template engines « COLD CASE September 4th, 2006 10:29 am

    […] read more | digg story […]

  40. Paweł `hwao` Halicki September 5th, 2006 10:02 am

    Oh, nice list!

    But I think polish project OPT is really great libary.

    Try test this
    http://opt.openpb.net/

    Greetings! :)

  41. justin September 5th, 2006 11:59 pm

    Thanks!

  42. Zyx January 21st, 2007 3:47 pm

    hwao :) . Thanks for promoting OPT among foreigners :) [I’m OPT author].

  43. fisher February 4th, 2007 10:20 am

    2 very fast engines were not mentioned at all:
    php_templates and blitz. Both are written in C and compiled as PHP-modules, they are much faster than most of other engines.
    http://sourceforge.net/projects/blitz-templates/
    http://sourceforge.net/projects/php-templates/

  44. […] Kaynak: Top 25 PHP template engines […]

  45. […] Tutti gli altri su: http://www.whenpenguinsattack.com/2006/07/19/php-template-engine-roundup/ Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages. […]

  46. kL February 20th, 2007 8:30 am

    PHPTal is the best one of them - it does not allow invalid HTML and properly escapes data. All others are just fancy find’n'replace text engines that easily create invalid tagsoup.

  47. […] Tutti gli altri su: http://www.whenpenguinsattack.com/2006/07/19/php-template-engine-roundup/ Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages. […]

  48. DocZayus April 13th, 2007 3:28 pm

    Be cool and build your own…

  49. […] Templates caching (a previous article I wrote describes some template engines here) […]

  50. Hildenborg » PHP html templates April 18th, 2007 2:26 pm

    […] PHP is fast and easy to use for creating dynamic html pages. One of the strengths in PHP is to be able to take any html page, rename it to php and put some php code directly in the html. And there you go, a working dynamic html page! The backside however is that the html code which is design related is mixed with the PHP code which is programming related. And in a normal project, one designer is doing the html code, and he most likely know nothing about PHP… And there is another person doing the PHP code, and he most likely knows nothing about design. Having those two guys working in the same file is not such a good idea… And here’s where template systems become interesting. There are several template systems for PHP out there, and the one you choose to use depends on your personal needs. I myself am currently involved in a project together with 040 internet, and first I thought about using smarty, but ended up using Phemplate as 040 internet’s designer already knew how to work with that. […]

  51. diyism April 20th, 2007 11:38 pm

    Look at here:https://sourceforge.net/projects/my-tpl
    The smallest php template engine on the world,
    totally based on ‘eval’ function of php.

  52. jp May 10th, 2007 11:39 am

    New PHP5 template engine with plain PHP:
    http://fry.sourceforge.net

  53. […] Templates are a great way to separate logic from presentation in an application. There’s no shortage of template engines available for PHP, so why would you want to write another one? Well, because sometimes you don’t need a full fledged template language like smarty, and writing your own simple engine is as easy as it is useful. […]

  54. Owen June 8th, 2007 7:14 am

    Thanks so much for the list, you just saved me hours of work.

  55. vanillahsu June 24th, 2007 9:46 am

    how about php_ctemplate?

    it’s php binding of google ctemplate library,

    almost 1000 reqs/sec.

  56. Leathorn June 27th, 2007 9:36 pm

    I didn’t see the template include in PHPlib on here. I have been using it for a while now. It’s easy to use and I haven’t had any speed complaints as of yet.

    The only thing it’s lacking (I think) is good documentation on how to use it. I found, when I first used it, that I had to go through examples and figure out what to do to get it to work correctly. Though, it isn’t hard to figure it out, and that was quite some time ago now. There may be some better documentation on how to use it now.

  57. Clip July 26th, 2007 10:15 am

    Thanks a lot for useful list.

  58. bayarsaikhan August 29th, 2007 11:55 pm
  59. Derianto August 31st, 2007 9:45 am

    After visiting some of the sites of the 25 template engines, I finally decided that the best (if possible) thing should be that the designers write the flow-controlling scripts __in English__ instead of in any programming languages.

    Actually it’s totally possible! This is the alternative solution to template engines:
    http://derianto.blogspot.com/2007/08/php-templating-solution-without-php.html

  60. All For Web » 25个顶级PHP模板引擎 September 14th, 2007 4:04 am

    […] 原文作者:Justin Silverton原文链接:Top 25 PHP template engines译者:子非鱼 […]

  61. All For Web » 25个顶级PHP模板引擎 September 20th, 2007 1:02 am

    […] 原文作者:Justin Silverton 原文链接:Top 25 PHP template engines 译者:子非鱼 […]

  62. Bart Goossens October 8th, 2007 5:37 am

    Codeignitor is also a easy to use template engine
    http://codeigniter.com/

  63. 25个顶级PHP模板引擎 | MyGoGou November 3rd, 2007 12:54 pm

    […] 原文作者:Justin Silverton 原文链接:Top 25 PHP template engines […]

  64. Figura November 7th, 2007 11:08 pm

    The ‘eval’ function is not a good idea for template engines because (I guess) it takes an additional time to execute the string by php interpreter. Template engines should compile temporary php files like ‘Smarty’.

    ‘Template engines are written on C and implemented as additional modules’ is also bad idea. Hosting companies can have restrictions and will not allow you to add new modules to PHP.

    Anyway, I do not like template engines because (it was mentioned before) they require knowledge about their syntax, specific and so on. An ideal solution for me seems in well thought-out structure of your project files. The logic and presentation should be separated as much as possible, but there is no crime if you add the ‘foreach’ construction (or something like this) into designer’s files. Initially, PHP language was intended to use in this way :)

  65. alex November 26th, 2007 11:23 pm

    Template engine? BARF! People - seriously move away from this. A waste of time and resources. using a templating engine is like me making a car key for my car key. there is nothing wrong with the first one. It is a waste of energy and to blunt freakin STUPID!

    Template engine? BARF! People - seriously move away from this. A waste of time and resources. using a templating engine is like me making a car key for my car key. there is nothing wrong with the first one. It is a waste of energy and to blunt freakin STUPID!

    oops… did I say this twice? I must have used a templating engine to post this comment. dang it… I just reapeated myself and doubled my work and server load. sorry about that. I do not like to repeat myself. I do not like to repeat myself.

  66. PHP Tema motorları | Teknolojik & Sosyal January 8th, 2008 11:19 am

    […] Kaynak:Top 25 PHP template engines […]

  67. sean January 17th, 2008 7:46 pm

    i agree with alex.

    if you want to use templates, put all the html in separate “template” files and use dumbed-down php code in them and then simply include those template files into your logic. template engines are NOT worth the added complexity and overhead. php was designed to be easily embedded in html.

    what’s so different about these, honestly?

    smarty: {if $foo}foo{/if}
    plain php: foo

    smarty is slightly prettier, yeah, but who gives a shit? the designer won’t get “confused”. it reads exactly the same.

  68. Zyx January 20th, 2008 7:24 am

    Personally, I really don’t like coding HTML generation in PHP. I find this language much too complex and long for such things. The simplest example: count, how many characters you must write in order to display one variable: - approx. 18-21. In template engine, there are only two easy-accessible characters: {$variable}.

    However, it’s also important, what template engine we use. I understand people who saw Smarty and said such libraries are a mistake, because I also find nothing interesting in rewriting ordinary loops, conditions and expressions into different syntax and that’s all. A useful template engine should work in this way: “Tell me, what you want to have, not how to implement it. It’s my business to make it work.” It’s possible to achieve. In my scripts, I only point places, which must be looped, are form fields etc. My TE knows that two nested sections mean a list and a connected sublist inside and how to connect them to the application logic; that form fields may display error messages, change the style if the data are not correct…

    So, if you ask, why I use template engines, ask yourselves, why you code your websites in PHP or any other scripting language, instead of C or assembler? My answer will look much the same.

  69. Simone 'Wiz' Tellini January 24th, 2008 6:15 pm

    PHP templates…

    When you design a complex application, it’s always useful to separate the presentation layer from the business logic. Usually, when dealing with web apps, this involves handing templates which are “filled” with data by your controller.

    The common…

  70. Templaterie Blog February 24th, 2008 11:29 pm

    […] 25 PHP template engines mit Kurzbeschreibung […]

  71. Aishiteruno March 1st, 2008 6:04 pm

    this is what i’m looking for, BIG THANKS

Leave a reply