so in routing.yml I have the following routes defined in order to edit and delete specific settings:
routing.yml:
settings.editDefaults:
path: settings/{id}/defaults/edit/{widgetType}
defaults: { _controller: AppBundle:Settings:editDefaults }
methods: [POST, PUT]
settings.deleteDefaults:
path: settings/{id}/defaults/delete/{widgetType}
defaults: { _controller: AppBundle:Settings:deleteDefaults }
methods: [DELETE]
And in my controller I have the correct actions defined: SettingController.php:
/**
* edit the default settings of a hotel/widget
*/
public function editDefaultsAction(Request $request)
{
//Edit logic
}
/**
* delete a default setting of a hotel/widget
*/
public function deleteDefaultsAction($hotelId, $widgetType)
{
//Delete logic
}
In the second action I only need the id
and widgetType
passed so I can query for and remove the selected record.
When I go to either of the routes I get the following:
Edit Route Error:
No route found for "GET /settings/2b2acd55-0dd6-11e5-8107-621ae3320fd4/defaults/edit/default": Method Not Allowed (Allow: POST, PUT)
Delete Route Error:
No route found for "GET /settings/2b2acd55-0dd6-11e5-8107-621ae3320fd4/defaults/delete/default": Method Not Allowed (Allow: DELETE)
But when I remove one and leave the other they work fine. I'm assuming it's the path definitions that are similar? Is it possible for me to keep the same paths and not get this error? What am I not understanding?
Thanks for your help, Anth
You only allow POST, PUT and DELETE methods, but you are accessing those routes via GET method.
so define your routes like this:
Or leave the DELETE, PUT and POST methods in, if you really need those restrictions and add GET method.
When you are accessing a URL with your browser, you are usually sending a your request via GET method. You can read more about these: Here And here