Hello!
At the moment I am studying Symfony 2 and this dilemma has arisen before me:
How best to store routes for controllers?
Yes, I understand that this question has a bit of holivar overtones, because the taste and color ... But still I am interested in this question from the point of view of organization of medium / large applications.
I will give my thoughts:
As far as I know, symfony has 2 main routes for storing routes
- In configs (routing.yml, routing.xml, etc.), it is also possible to connect routing from bundles.
- In the annotations
The variant with annotations seems to me to be the most convenient, but when there are a lot of controllers and methods, say 50+, there will be a difficulty in determining what is and where, and as a result, development and debagging complications.
It also seems acceptable to me to put routes into the routing files of each bundle. In this case, it will be convenient to reuse bandlets in other projects, and knowing what functionality a particular bundle is responsible for, look for the necessary routes. But still with a large number of bundles this can be a problem.
The third option is to store all the routes in app / config / routing.yml. But it will complicate the reuse of bundles. And, for some reason, I intuitively dislike this option.
From the side it may seem that I asked the question and answered it myself. This is not true. I see these options, but I don’t know which one to use and when, since there’s no experience with any serious Symfony development.
I will be glad and grateful to any opinions, and in twofold - to the opinion that is reasoned.