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

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

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

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.

TinyButStrong

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

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

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.

vlibTemplate

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

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

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

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

Answerbase
WebResourcesDepot Feed