I'm developing an API using Symfony and FOSRestBundle, and want to use the following routes:
app/config/routing.yml
page:
prefix: /page
resource: "@PageBundle/Resources/config/routing.yml"
PageBundle/Resources/Config/routing.yml
page_get:
path: /{id}
methods: GET
defaults:
_controller: PageBundle:Page:get
id: null
page_post:
path: /
methods: POST
defaults:
_controller: PageBundle:Page:post
The same for PUT and DELETE...
When I call GET for /page works fine, but when call POST for /page I get the following error:
No route found for "POST /page": Method Not Allowed (Allow: GET, HEAD)
I need to call /page/ instead of /page, then it works...
What can I do to use the same empty path for differents methods?
Sorry for my bad english.
What you need to do is remove prefix
from app/config/routing.yml
page:
resource: "@PageBundle/Resources/config/routing.yml"
And add it to path in PageBundle/Resources/Config/routing.yml
moodul_page_get:
path: /page/{id}
methods: GET
defaults:
_controller: MoodulPageBundle:Page:get
id: null
moodul_page_post:
path: /page
methods: POST
defaults:
_controller: MoodulPageBundle:Page:post
Hope this helps