I am trying to use Symfony 2 with FOSRestBundle, I've got my GET
and POST
functions working fine and i've got it returning an array fine with PUT however i cannot get my query string or input.
I've tried the obvious $_POST
, $_GET,
$_PUT
and even tried file_get_contents("php://input
"); none of these return a query string.
I am lead to believe that PUT
is used to update an existing entry which i am doing.
Any assistance would be greatly appreciated.
That's documented here: https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Resources/doc/3-listener-support.md#param-fetcher-listener
Let me give you an example:
/**
* @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');
...
}
That way you'll be able to fetch query params.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.