L
L
Lone Ice2017-09-13 09:26:02
PHP
Lone Ice, 2017-09-13 09:26:02

Which template engine for PHP to choose?

I understand and know that PHP is already a templating engine in itself, but the question is still the same. Which ones did you use, which ones are used in frameworks? What is the point of dividing the layout into over9000 pieces and then running through the files in search of the desired element (I hated PrestaShop after that)? Now, in fact, there is a choice between using a template engine and the old-fashioned code: all calculations until the html output, and then directly the output itself in the same module with ifs, foreachs and other joys (but without queries to the database and layout in variables) . Where can you win in terms of speed (and is it necessary)?

Answer the question

In order to leave comments, you need to log in

6 answer(s)
D
DevMan, 2017-09-13
@daemonhk

Where can you win in terms of speed (and is it necessary)?
in terms of speed, clean puff will be faster.
only faster it will be quite insignificant: in order for the template engine to become a bottleneck, you need to try very hard to fill it up.
in other words - the aspect of speed can not be considered at all.
What is the point of dividing the layout into over9000 pieces and then running through the files in search of the desired element
in code revision. normal template engines support template inheritance, which avoids duplication of almost identical pages.
well, no one forces you to share, you can use monolithic templates in the old fashioned way.
which one to use is a matter of taste. I prefer django-like syntax, so I use twig.
well, if you can drop the base from the template - it's anything but a template. it to a question "whether the templating engine is necessary".

E
Evgeny Kalibrov, 2017-09-13
@rework

TWIG ( https://twig.symfony.com/ ) is a good templating engine. I used it once when developing my framework in PHP

Z
zooks, 2017-09-13
@zooks

I confirm, Twig is good. If you are using Laravel, but too lazy to screw Twig, then Blade.

C
Comandante Fidel, 2017-09-13
@cmdfidel

I recommend the good old Smarty. It is somewhat slower than Twig, but in my opinion it has a more sane syntax and is much easier to extend.

D
Dmitry Mironov, 2017-09-13
@MironovDV

In my projects I use twig ( https://twig.symfony.com/), in my projects, pure php is at work, the only minus of template engines is that you can’t just copy html from the Internet and paste it, for example, I used twitter bootstrap and I had to rewrite each example on twig.

Z
zorca, 2017-09-14
@zorca

Twig or Blade, the second one can be pulled to any project through some adapter, for example: https://packagist.org/packages/duncan3dc/blade
Our studio switched to Blade when creating themes for Wordpress, very convenient. The code is nice and clean.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question