Reputation: 21
I have a bundle AcmeDemoBundle. I would like it to use both annotations within a controller and a routing.yml file for routes. If I use the CRUD generator, I like how it already defines my routes, takes care of all my work and for those pages that done really need CRUD components, like say an About us page, it would be better off creating a route in routing.yml.
app/config/routing.yml:
AcmeDemoBundle:
resource: "@AcmeDemoBundle/Resources/config/routing.yml"
resource: "@AcmeDemoBundle/Controller"
type: annotation
prefix: /
This returns errors so I know it is wrong, if I take off one resource the other does not work :(. Please let me know if there is a way to do this.
Upvotes: 2
Views: 2575
Reputation: 283
You need to do something like that
acme_test:
resource: "@AcmeDemoBundle/Resources/config/routing.yml"
prefix: /
acme_dummy:
resource: "@Acme/Controller/DummyController.php"
type: annotation
prefix: /
Upvotes: 0
Reputation: 25315
I could be wrong, but I don't think it's possible to use both yml routes and annotation routes in the same bundle. I remember trying to get it to work myself and not having much luck. But even if it is possible, I would recommend sticking with one format. You may be able to keep track of where each route is defined right now, but as the project becomes more complex (read: more routes) and time goes on, you'll have a tougher time keeping track of where each route is defined. When you have to revisit the project 6 months later, you'll be glad you only have routes defined in one place. This is also important if other people are going to work with this code - it'd be much easier for them if the routes were all defined in the same fashion.
Upvotes: 2