Recommended Template Engine for PHP

i just want to know your inputs on what template engine you use when building a site.

PHP itself.

I recommend smarty. Its widely used and provides better performance.

Better performance than what?

My recommendation? Twig.

smarty is for dummies. PHP is a template engine. Putting a template engine in PHP is like buying a semitruck, then towing the semitruck around with a pick up truck.

I’ve had this rant before and am not going to do it again. Do a search of posts I’ve made containing smarty and you can read the previous rants. Smarty is the worst thing you can do to your code.

I will confess: when I want templates, I use FastTemplate. It’s old and unsexy. But it’s fast, easy to use, and it keeps all the logic in the PHP code where it belongs. The templates can easily be edited by someone who knows nothing about PHP; they have no PHP tags in them to inadvertently get messed up or deleted – just variable names surrounded by {}. Works for me.

There are some advantages to using smarty, Twig, etc but you should clearly understand those benefits before determining whether to use Smarty over PHP - typically PHP is a acceptable template engine.

Cheers,
Alex

Here a good benchmark that shows template engines performances

I use Rain TPL, it’s the simplest to use and so far the faster, create template is fun and give me satisfaction

wow! I’ve never used Smarty, and that benchmark doesn’t encourage me to start. 10x the execution time of native PHP?