19 Promising PHP Template Engines
PHP template engines are used widely to seperate the code & the layout.
This makes a website easier to maintain/update & creates a better development environment by enabling developers & designers to work together easier.
It sure has some drawbacks which is generally the performance (most libraries offer great solutions there) & need to learn a new syntax (not always).
To mention, using a template engine may not be suitable for every project. A website with few pages will probably won’t need it. But it can improve the development process of a portal, an e-commerce site or another web application easily.
Here are 19 PHP template engines with very nice features & have a continious development:
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 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..
A lightweight templating engine for PHP.
it uses PHP itself as its template language & no need to learn a new markup system.
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!
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.
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.
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 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.
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, 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, 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 allows you to store your HTML code separately from your PHP code.
It has many useful features yet code is short, highly optimized & used in various commercial & open source projects.
vlibTemplate is a class for templating PHP applications. It is normally included in the vlib package which has the following 3 classes:
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.
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.
FXL Template an easy to use template engine covering all the basic features of a template system.
- simple text/array assignments
- nested blocks.
The template markup is really easy to learn & for high traffic enviroments a "memcached" cache extension exists.
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).
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 and rows['name'])
- For-each looping over arrays (associative and numerically indexed)
- Includes (included templates are parsed and cached separately)
Template Engines Under PEAR
4 PEAR packages on templating:
QuickSkin, previously known as SmartTemplate, works like a ‘template compiler’ that converts templates into executable PHP code and stores it for later reuse.
- 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?
- 1 line template engine
- A templating class called Bob
- How to write a simple PHP template engine
- Phammable: HAML parser / integration framework for PHP
- Making XML/XSLT driven site using PHP
- TemplateTamer – PHP template development tool