How to create custom routes for some actions using FOSRESTBundle?

I use automatic route creation for my Rest api using FOSRESTBundle , also I use NelmioApiDocBundle to generate api doc.

To create routes for api that I have in my routing.yml

users: type: rest resource: Project\RESTBundle\Controller\UsersController 

But for some actions I want to configure my custom routing ... If I try to add another route rule for the action, it simply ignores it and generates an automatic route.

+4
source share
1 answer

You must declare a route with the same name immediately after the setting that you set. For example, the following work.

 users: type: rest resource: Project\RESTBundle\Controller\UsersController get_users: pattern: /api/users/customUri.{_format} defaults: { _controller: ProjectRESTBundle:Users:indexAction, _format: json } 
+8
source

All Articles