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.
74 Comments so far
Leave a reply






Nice, Thanks!
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.
thanks for the suggestion. I didn’t even know about that templatate engine. I try it out.
Please add PEARs HTML_Template_IT. I use it for all my projects and find it very good. You should give it a try…
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;-)
All you need is eval(). Anything else is baggage.
Smarty.. pffft.
Thanks for your list!
It misses smarttemplate engine (http://smarttemplate.sf.net)
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
Another one.
http://www.php-tools.de/site.php?file=patTemplate/overview.xml
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.
I have always used Savant, which is a non compiled template engine, but very useful.
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?
missing pattemplate (http://www.php-tool.de). Much easier to work with than smarty and very powerful.
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.
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.
I’m sorry that’s http://jquery.com
You also forgot about patTemplate from php-tools. Not as evolved as Smarty, but nice and powerfull for a small and limited use.
People, this list says Top 25, not “a list of PHP template engines”.
Xaraya’s blocklayout is a great engine - too bad it’s too tightly coupled to the rest of the framework… :-/
phpsavant.com missing
what about HTML::Template by Sammy boy. It’s da bomb you!
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.
How about template-lite? (used to be called smarty-lite). I find it very versatile and quick…
http://templatelite.sourceforge.net/
Do any of them work with CakePHP?
QuickTemplate…
http://quicktemplate.sourceforge.net/
What about Flexy, mmm duh.
super cool list…
i think even flickr from yahoo is using smarty only..
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
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.
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.
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.
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.
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.
Savant is better. http://www.phpsavant.com
I agree with what you said.
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
Smarty - the best
How about PHPLIB?
http://sourceforge.net/projects/phplib
Supposedly faster than Fast Template. Around since 1999
[…] read more | digg story […]
Oh, nice list!
But I think polish project OPT is really great libary.
Try test this
http://opt.openpb.net/
Greetings!
Thanks!
hwao
. Thanks for promoting OPT among foreigners
[I’m OPT author].
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/
[…] Kaynak: Top 25 PHP template engines […]
[…] 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. […]
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.
[…] 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. […]
Be cool and build your own…
[…] Templates caching (a previous article I wrote describes some template engines here) […]
[…] 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. […]
Look at here:https://sourceforge.net/projects/my-tpl
The smallest php template engine on the world,
totally based on ‘eval’ function of php.
New PHP5 template engine with plain PHP:
http://fry.sourceforge.net
[…] 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. […]
Thanks so much for the list, you just saved me hours of work.
how about php_ctemplate?
it’s php binding of google ctemplate library,
almost 1000 reqs/sec.
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.
[…] http://www.whenpenguinsattack.com/2006/07/19/php-template-engine-roundup/ […]
Thanks a lot for useful list.
60+ template engines for JAVA, PHP and .NET
http://www.plentyofcode.com/2007/08/60-template-engines-for-java-php-and.html
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
[…] 原文作者:Justin Silverton原文链接:Top 25 PHP template engines译者:子非鱼 […]
[…] 原文作者:Justin Silverton 原文链接:Top 25 PHP template engines 译者:子非鱼 […]
[…] http://www.whenpenguinsattack.com/2006/07/19/php-template-engine-roundup […]
Codeignitor is also a easy to use template engine
http://codeigniter.com/
[…] 原文作者:Justin Silverton 原文链接:Top 25 PHP template engines […]
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
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.
[…] Kaynak:Top 25 PHP template engines […]
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.
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.
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…
[…] http://www.whenpenguinsattack.com/2006/07/19/php-template-engine-roundup/ […]
[…] 25 PHP template engines mit Kurzbeschreibung […]
this is what i’m looking for, BIG THANKS