I remember when I first started using Symfony 1.0 in a PHP web development shop. We had backend programmers, front-end developers and designers. The designer would create the design. Then, the front-end developer would create the html/css with place-holders for the dynamic data from the design. And then I would go in and replace the place-holders with php code to create the dynamic page. We had a great system that worked well.
We only used very short PHP snippets in the views so that it was more readable to the front-end developers who usually didn’t know much PHP code. We tried to keep the PHP to one line at time instead of complete blocks of code. This made it easier to remember that the business logic went in the controller or the model, not the view.
The tutorial says that Twig makes the views more concise and easier to read for designers. Maybe. Maybe Twig is a little easier for them to understand than PHP when they see it, but I’m not sure it will be any easier for them to write. My guess is that I’ll still be writing the Twig code in the template. I’m sure my front-end developers will pick it up, but it’s going to be interesting to see how difficult they find it to be.
I do like the {% block %}
tags so that they can be overridden. And I like that templates can extend other templates. That will definitely cut down on development time. I also like the idea of the filters and functions. I’m anxious to dive into twig and learn more about all these.
So, not a lot of code to play around with in this tutorial so it didn’t really matter that my code doesn’t match theirs. Next, we’ll jump into the Getting Started ‘Controller’ tutorial.