3

我使用 Symfony2.2 和 FOSRestBundle

我设置

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

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

我的 UserController 扩展了 FOSRestController 并具有方法cgetAction()newAction(). 当我尝试路由器:调试时,路由显示:

.. symfony 路线 ..

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

根据文档,我所期望的类似于

"get_users"     [GET] /users

我错过了什么?

4

1 回答 1

3

我建议你阅读路由文档。如果你想要 /users,你必须使用 getUsersAction:

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

否则请阅读隐式资源名称定义部分。

FOS 休息路由

于 2013-03-25T10:16:54.440 回答