A while ago the Symfony project published a “Best Practices” book.
This is a source of excellent suggestions and it’s written by the people who wrote Symfony in the first place, so we decided to stick to it as much as possible, even in those few cases where the benefits where not immediately clear.
But after a few more Symfony projects, there is one best practice that I definitely want to question: the location of the templates.
The book says they should reside in
/app/Resources/views. The main benefits are:
While the first point is definitely true, the second loses its meaning since, elsewhere in the book, it is suggested to have a single bundle in your application.
If you follow the best practices, during development you’ll keep jumping from
/app/Resources/views and back.
/app folder contains a lot of miscellanous things:
I don’t know about you, but I see all these as the extra parts required to makes Symfony work, while the templates are a core part of my application and as such, I definitely feel it’s more logic to have them in the
A big bonus of this approach is that you can simply delete and recreate the
/src folder on deploy, since it’s got nothing that should last between deploys (this avoids issues about leaving obsolete files around).
Starting from my next project I will move the templates back into
That’s my best practice 🙂