Permana
Permana

Reputation: 1991

FOSRestBundle route

I use Symfony2.2 and FOSRestBundle

I set

#app/config/config/yml
myapp_rest:
    resource: "@MyappRestBundle/Resources/config/routing.yml"
    type: rest
    prefix:   /v1

and

#src/Myapp/RestBundle/Resources/config/routing.yml
user:
    resource: Myapp\RestBundle\Controller\UserController
    type:     rest

my UserController extends FOSRestController and have method cgetAction() and newAction(). And when I try to router:debug, route shows:

.. symfony routes ..

get                       GET    ANY  /v1/{id}.{_format}
new                       GET    ANY  /v1/new.{_format}

what I expected, according to the docs, is something like

"get_users"     [GET] /users

what am I missing?

Upvotes: 3

Views: 3182

Answers (1)

Baba Yaga
Baba Yaga

Reputation: 1819

I suggest you read the routing docs. If you want /users you have to use getUsersAction:

public function getUsersAction() {} // "get_users" [GET] /users

Otherwise read the Implicit resource name definition section.

FOS Rest Routing

Upvotes: 3

Related Questions