If I understand your question correctly, you are asking how to create a URL by passing the module name and action name instead of the route name. It is right?
I do not think this is possible in Symfony2. If you look at the generate method in Symfony\Component\Routing\Generator\UrlGenerator , you will see that it expects the name of the route as the first parameter. In addition, Symfony2 does not support the main routes that symfony 1 runs (see below for reference).
default_index: url: /:module param: { action: index } default: url: /:module/:action/*
Without these shared routes, you cannot simply access / myModule / myAction without actually defining a route for it. And don't forget that Symfony2 now uses packages, which would complicate this further.
So, for any actions that you want to access, you need to write routes for them.
To really generate urls ...
- From the controller: $this->generateUrl($routeName);
- From the PHP template: $view['router']->generate($routeName);
- From the Twig pattern: {{ path('_routeName') }} or {{ url('_routeName') }} for an absolute URL
source share