Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 561
Permana Avatar asked May 21 '26 22:05

Permana


1 Answers

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

like image 113
Baba Yaga Avatar answered May 23 '26 10:05

Baba Yaga