Why I get "amp;" in array keys from getQueryParams?

Hi, I use Slim with thephpleague/oauth2-server and can not get the query params correct.
I have a ServerRequestInterface $request variable, when I use json_encode($request->getQueryParams()) I get this result:

{“authorize”:“”,“amp;response_type”:“code”,“amp;client_id”:“myclient”,“amp;redirect_uri”:“localhost”,“amp;state”:“1”}

The URL is:

https://testserver.local/api/oauth2/authorize?response_type=code&client_id=myclient&redirect_uri=localhost&state=1

And .htaccess file:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ auth.php?$1 [L,QSA]

What am I doing wrong?

It seems like the current rule is causing the issue and how your server is handling the request.

RewriteRule ^(.*)$ auth.php?$1 [L,QSA]

Here’s an example of how you can set up your .htaccess file to correctly pass the query parameters to your Slim 4 application:
Example:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

Also make sure that your server is properly configured and that there are no additional custom URL rewriting rules that might interfere with the query parameter handling.

I would recommend reading this:

Hi Odan, thank you for the replay. If I change the .htaccess I get this array with the same URL:

{“response_type”:“code”,“amp;client_id”:“myclient”,“amp;redirect_uri”:“localhost”,“amp;state”:“1”}

P.S. the PHP $_GET variable is correct: {“response_type”:“code”,“client_id”:“myclient”,“redirect_uri”:“localhost”,“state”:“1”}
but oauth2-server uses getQueryParams and don’t work properly…

It seems that the “amp;” prefix is being added to each query parameter, which is not expected behavior. I guess the problem is somewhere in the request handling process, these entities are not being properly decoded. Can you provide more details, such as the installed PSR-7/PSR-15 packages and other installed Middlewares?

Ok, it work now. That was a conflict with WHMCS (I built it as a WHMCS module). Composer somehow used the modules from the WHMCS vendor directory. If I separate that from WHMCS then it works.