Search code examples
phpsymfonyyamlfosrestbundle

FOSRest bundle remove trailing s on routes


I have an issue with the FOSRest bundle and I am using Symfony 2.
My problem is that FOSRest adds a trailing s to post routes.

I have a function in my AccountBundle\settings controller

public function postAccountSettingsAction()
{
    //
}

Now when I debug the routes it shows me

POST            accounts/settings.{_format}

My routing looks as following

settings_v1:
     type: rest
     resource: "........\Controller\SettingsController"
     prefix: /v1
     name_prefix: v1_

settings_v2:
     type: rest
     resource: "........\Controller\SettingsController"
     prefix: /v2
     name_prefix: v2_

I don’t want to have accounts/settings but I want account/settings
So my question: is it possible to get rid of the trailing s?


Solution

  • I don't think it's possible to configure that globally. There is a pull request on the repository of the project to add this functionality but it hasn't been merged yet.

    You can still define your own URL on the controller, but you will loose the automatic route generation :

    /**
     * @Post("/account/settings")
     */
    public function postAccountSettingsAction()
    {
        //
    }