By using the QueryParam
annotation, you declare that the $user
parameter is supplied as a query parameter (like /api/user/details?user=foo
), so there are no more action parameters left to include in the route.
If you want to add requirements to the auto-generated route, you have to use the @Rest\Route
annotation instead, as in
/**
* @Rest\View
* @Rest\Route(requirements={"user"="\w+"})
*/
public function getDetailsAction($user) {
-----
}
Note that there is no equivalent to the strict
or nullable
options. If the requirements aren't fulfilled or the parameter is missing, the route simply won't match, which leads to a 404 error if no other route matches the request. Also, AFAIK there is no way to attach a description to route parameters.