well I'm a php programmer who for a period create some php application by using codeigniter framework. Now I would pass to the next level using a framework more powerful and my choose is gone to symfony framework. I read good things about it and looking for some infos about it, it seems me a good next level. I saw that it uses a templates engine names Twig and since I come from codeigntiter I fell a little uncomfortable.now I would know which are the advantages in using twigs?is it really of help using it in web application?
2 Answers
In my short, subjective opinion, templating engines typically result in cleaner views, and in some engines' cases (some more than others), better enforcement of separation of concerns.
As far as discussions & articles go, there are many if you search for them. Here are a few references though:
- What are the real advantages of templating engines over just using PHP?
- PHP vs template engine
- (older, and also could be biased towards Twig since it was written by Fabien)
http://fabien.potencier.org/article/34/templating-engines-in-php
Twig's website even gives you an overview of why it can be helpful:
http://twig.sensiolabs.org/
One thing to keep in mind regarding Symfony is that you are not locked in to using Twig. In my opinion, it's easier if you do, but you can just as easily tell Symfony you want to use straight PHP templates instead.
Twig is dead simple yet powerful templating language, and is just a bunch of shortcuts to what you'll do in PHP.
There is cool built-in tools like filters to avoid inline php common treatments on strings (for example), macros and possibility of extending the language. The syntax is very clean, and easy to learn.
There is a great documentation.

- 3,630
- 3
- 26
- 38