모든 주석에 대한 정보를 공유하고 싶습니다.
@Get, @Post, @Put, @Delete, @Head, @Patch 대신, 당신은 단지 하나를 지정할 수 있습니다 그들 모두를 사용하여, @Route + @Method에 대한 바로 가기입니다 예 :
/**
* @Get("/hello/{id}")
*
*/
public function helloAction($id)
{
return array();
}
정보에 대한 @View는 문서에 있습니다 https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Resources/doc/3-listener-support.md
@View //Guess template name
@View("AcmeHelloBundle::layout.html.twig") //Load Resources/views/layout.html.twig
@View("AcmeHelloBundle::layout.html.twig", templateVar="test") // if returned data doesn't
// have a key (e.g. return array("string", 5) instead of default variable 'data',
// it's placed inside 'test' variable inside template.
@View(statusCode=204) // set HTTP header's status code
이름 접두사이 routing.yml 파일 또는 주석으로 하나를 추가 할 수 있습니다. 또한 설명되어 있습니다 - https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Resources/doc/6-automatic-route-generation_multiple-restful-controllers.md :
때때로, 라우팅 자동으로 이름이 너무 RestBundle 경로 컬렉션 매개 변수 (주석 XML/YML 및 @NamePrefix에 대한 이름 접두사)를 name_prefix을 제공, 경로 이름 충돌로 이어질 것 :
이 구성
#src/Acme/HelloBundle/Resources/config/users_routes.yml comments:
type: rest
resource: "@AcmeHelloBundle\Controller\CommentsController"
name_prefix: api_
는, 경로 이름이 될 것입니다 : api_vote_user_comment
@Prefix은 부모 리소스가 있고 하위 리소스 전에 접두사를 추가해야하는 경우 특히 유용합니다. 예 :
부모 :
class UsersController extends Controller
{
public function getUserAction($slug)
{} // "get_user" [GET] /users/{slug}
}
아이 :
class CommentsController extends Controller
{
public function getCommentAction($slug, $id)
{} // "get_user_comment" [GET]
}
지금 액션 getCommentAction이
/사용자/{슬러그}에 해당하는/댓글/{ID} 경로.
@prefix 함께
("some_prefix") 발생 경로 것이다/사용자/{슬러그}/some_prefix/의견/{ID}
그리고 @NoRoute 메소드 레벨의 주석을 사용하여
, 경로 생성되지 않습니다.