Slim4 not parsing well URI with question mark included

Hi. I’m trying to read GET parameters using Slim4, but the method getQuery shows the query with question mark included, that affects the parsing when I’m reading parameters with getQueryParams Method:

This is an example: getQueryParams, query and uri request

Array
(
    [?page] => 1
    [limit] => 10
)

query:?page=1&limit=10

uri:Slim\Psr7\Uri Object
(
    [scheme:protected] => http
    [user:protected] => 
    [password:protected] => 
    [host:protected] => localhost
    [port:protected] => 80
    [path:protected] => /3dm/3dmbovia/public/tdm/index.php/api/subscription
    [query:protected] => ?page=1&limit=10
    [fragment:protected] => 
)

I’m using

slim 4.0.0
slim/flash               0.4.0              Slim Framework Flash message service provider
slim/php-view            3.2.0              Render PHP view scripts into a PSR-7 Response object.
slim/psr7                1.6.1              Strict PSR-7 implementation
slim/slim                4.0.0              Slim is a PHP micro framework that helps you quickly write simp...
slim/twig-view           2.5.0              Slim Framework 3 view helper built on top of the Twig 2 templat...

Please help.

I could fix by myself. I had error in my NGINX config. I had /index.php?$is_args$args instead of /index.php$is_args$args.

1 Like