Query Params on get route


#1

I want to have this url www.mydomain.com/api/operations?pageNumber=1 but I do not know how to implement that in the routes files, I try doing this

$app->get(’/operations?pageNumber={id}’, ‘OperationController:GetByPaginated’)->add(‘LoginMiddleware’);
but the server respond with a 404 error.

could anyone help me with this?
thanks


#2

Hi,

Slim uses only the path of the URI, not the query params.

please try $app->get(’/operations’, ‘OperationController:GetByPaginated’)->add(‘LoginMiddleware’);

you can access the query params via the getQueryParams() method of the ServerRequestInterface parameter of your callback.