How to GET all parameters from link

Hi everyone,
check this:

$this -> get(’/category/{id}/{name}[/{params}]’, function($request, $response, $args) {
$Offers = new Offers($this -> db);

}) -> setName('catalog-category');

and if i go to page like this:

i want to get from $_GET superglobal filter2 value, minPrice value, maxPrice value, all $_GET array, but this doesnt work.
whats the problem?


Have you tried this?


@odan sorry, my mistake. My routing looks like this: $this -> get(’/category/{id}/{name} without params. And if i write $args[‘name’] the results is name from routing and data which i want from $_GET variable, but i want all $_GET parameters in array :confused:

In this case you must format the url query string correctly.

A query string starts with a ?, the following parameters are separated by &.

Here is a correct URL (example):

Slim 3 is based on PSR-7 (HTTP Message). Therefore you have to get all request parameters from the $request object.

You can get the query parameters as an associative array on the Request object using $request->getQueryParams().

You can also get a single query parameter value, with optional default value if the parameter is missing, using $request->getQueryParam($key, $default = null).

$filter2 = $request->getQueryParam('filter2');

The prerequisite is, however, that the URL (as described above) is correctly formatted.