[英]PHP FOSRestBundle using PUT method
我正在嘗試將Symfony 2與FOSRestBundle一起使用,我的GET
和POST
函數工作正常,並且我使用PUT返回了一個數組,但是我無法獲取查詢字符串或輸入。
我已經嘗試過明顯的$_POST
, $_GET,
$_PUT
,甚至嘗試過file_get_contents("php://input
”); 這些都不返回查詢字符串。
我相信PUT
用於更新我正在做的現有條目。
任何幫助將不勝感激。
在此處記錄: https : //github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Resources/doc/3-listener-support.md#param-fetcher-listener
讓我給你舉個例子:
/**
* @View(statusCode=200)
* @Put("/resource/{resource_id}")
* @QueryParam(name="page", requirements="\d+", default="1", description="Page of the overview.")
*/
public function putAction(ParamFetcher $paramFetcher)
{
$page = $paramFetcher->get('page');
...
}
這樣,您將能夠獲取查詢參數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.