I’ve been using Symfony for a long time but I’m new to Symfony2. After using the CRUD generator to generate scaffolding for a module called MediaArea, I edited my routing to include this rule:
_welcome:
pattern: /
defaults: { _controller: VNNPressboxBundle:MediaArea:new }
When I visited that page in the browser, I got this error:
An exception has been thrown during the rendering of a template
(“Route “mediaarea_create” does not exist.”)
When I create the route, naturally, the error goes away. Here’s the route:
mediaarea_create:
pattern: /foo
defaults: { _controller: VNNPressboxBundle:MediaArea:create }
So I could manually create all the routes I need to – mediaarea_create, mediaarea_index, etc. – but that would be dumb. Is there a way to tell Symfony that I have all these mediaarea routes that I need to work?
EDIT: ok, may not answer the question, it’s just a long comment…
Why not using an
abstractbase controller with annotations instead?If your subclasses need a different behavior you can always override
showAction()or add any action you want. Then you just need to importMediaControllerandUserControllerin yourrouting.yml(just one import for each controller):Your routes then becomes automatically
acme_hello_media_showandacme_hello_user_show. Debug with: