Query Params on get route

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

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.

1 Like