Variable on a prefix on symfony2 routing

routes, symfony

Solution

Have you tried this?

//app/config/routing.yml
god:
    resource: "@Acme/DemoBundle/Resources/config/routing.yml"
    prefix: /god

and then something like this in the bundle routing file:

gods_route_to_heaven:
    path: /{religion}/path_to_heaven
    defaults: { _controller: AcmeBlogBundle:God:show }

Let me know if it works.

Problem

I need a variable on a prefix on my symfony2 routing so that i can do something like this in the main routing file: ``` //app/config/routing.yml god: resource: "@Acme/DemoBundle/Resources/config/routing.yml" prefix: /god/{religion} ``` and then something like this in the bundle routing file: ``` gods_route_to_heaven: path: /path_to_heaven defaults: { _controller: AcmeBlogBundle:God:show } ``` so that i can access paths like this: ``` /god/Christianity/path_to_heaven /god/Islam/path_to_heaven /god/Hinduism/path_to_heaven ``` and so on. If i type `app/console route:debug | grep api` on the console i get the correct route `/god/{religion}/path_to_heaven`, so the route is being generated correctly. But when I try to get the parameter in the controller by placing it as an input in the action function like this: ``` public function showAction($religion) ``` the path gets corrupted and dumping the paths i see it gets duplicated: `/god/{religion}/path_to_heaven/{religion}` So how would i get the $religion variable from inside the controller?

Original source

Related problems