3

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?

Permana
  • 1,972
  • 2
  • 33
  • 51

1 Answers1

3

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

Baba Yaga
  • 1,819
  • 15
  • 20
  • Thanks, I miss the `implements ClassResourceInterface`. It works as expected now. I am using implicit resource name – Permana Apr 01 '13 at 00:25