在Symfony2中,使用多单词名称并获得良好的RESTful url的最佳方式是什么

在Symfony2中,使用多单词名称并获得良好的RESTful url的最佳方式是什么,rest,symfony,Rest,Symfony,我正在使用FOSRestBundle构建我的symfony2api 我有一些称为SupportRequestTemplate的实体,我希望在API端点中看到这些实体,但当我创建名称为 getSupportRequestTemplateAction(Request $request, $id) {} FOSRest将每个驼峰大小写单词视为一个新的资源名称,因此我得到的url是 /api/supports/{id}/request/template.json 看起来很糟糕。有没有办法让终点看起来

我正在使用FOSRestBundle构建我的symfony2api

我有一些称为SupportRequestTemplate的实体,我希望在API端点中看到这些实体,但当我创建名称为

getSupportRequestTemplateAction(Request $request, $id) {}
FOSRest将每个驼峰大小写单词视为一个新的资源名称,因此我得到的url是

/api/supports/{id}/request/template.json
看起来很糟糕。有没有办法让终点看起来像这样

/api/support-request-templates/{id}.json
还是我必须接受它,然后去所有的小写字母,比如

/api/supportrequesttemplates/{id}.json

您可以使用注释根据需要自定义url。 例如
@Get

use FOS\RestBundle\Controller\Annotations as Rest;

/**
 * @Rest\Get("/api/support-request-templates/{id}.json")
 */
public function getSupportRequestTemplateAction($id, Request $request)
{
    ...
}

您可以在中阅读有关这些注释的更多信息。

您可以根据需要使用注释自定义url。 例如
@Get

use FOS\RestBundle\Controller\Annotations as Rest;

/**
 * @Rest\Get("/api/support-request-templates/{id}.json")
 */
public function getSupportRequestTemplateAction($id, Request $request)
{
    ...
}

您可以在中阅读有关这些注释的更多信息。

这正是我所需要的,我做了一些细微的更改(从.yml文件的注释中删除一些路线信息),但在其他方面效果很好。这正是我所需要的,我做了一些细微的更改(从.yml文件的注释中删除一些路由信息)但在其他方面效果很好。