Interested to know the pros and cons of using PHP Template engines.
For further actions, you may consider blocking this person and/or reporting abuse
Interested to know the pros and cons of using PHP Template engines.
For further actions, you may consider blocking this person and/or reporting abuse
Roxana Maria Haidiner -
Sushant Gaurav -
Andrew Darfoor -
MD ARIFUL HAQUE -
Top comments (12)
I would suggest you go for Twig, if I remember well you can build your templates using the Twig syntax or even PHP
But go for templates as they are reusable (can have different parts built together), inheritable (you can have a master template and keep overriding different parts) and performant (as good as PHP code)
No need to have HTML, CSS or JS in your controllers
PS: The templates are supported in your regular IDE like PhpStorm, Atom, Visual Studio code with autocomplete etc
Thank you, Stephan, for the thoughts!
Clearly yes ! (and a framework if you don't use one)
I use Symfony and twig since >1 years and this is so cool and clean.
For my job i also work with java and i deplore the poor quality of templates engines :(
Twig is very simple and very powerful, you can use custom function and filter, this is a little tricky at the first but when you know how to use it you earn so many time.
Thanks, I'll definitely gonna use twig.
I use Twig a lot. I'd say a pro would be that your templates will be waaay neater than pure PHP while the obvious con is that you have to learn yet another language.
If you want to give it a shot, it works wonders with Symfony. Look it up.
Sure, Thanks for the feedback Laurentiu :)
Twig is very good, I begin using it on D8 and some flat file CMS's like Pico, it's based on Jinja
Thanks for the reply, Esteban. I'm on it!
I have used plates from the php league and blade from laravel. I strongly suggest using any template system over no template system. For a decade I was working at a place where 3rd party code was frowned upon. Slowly but surely over my years my code evolved to contain some basic concepts common to plates and blade. When I left that job and finally used a real template system I wanted to kick myself.
Definitely recommend using a template engine for PHP to separate presentation and html from PHP. Smarty has been around for a very long time and I highly recommend it.
Thanks, I'm working on a crowdfunding platform (similar like Kickstarter).