getQuery('page') = null in cakephp 3.6


// URL is /Personas/index?page=1&sort=title
$page = $this->request->getQuery('page');

It makes me null and void all the time.

in Controller:

public function index() {
$page = $this->request->getQuery('page');

in Routes:
$routes->connect('/index/*', ['controller' => 'Personas', 'action' => 'index']);


With sort or any other parameter passed through url does nothing, this only happens to me with pagination.

1 Like

I can’t replicate your problem in Cakephp 3.8.5

If you do $this->request->getQueryParams() can you confirm that the value is present?


$params = $this->request->getQueryParams();


**/src/Controller/PersonasController.php** (line **236** )
Array ( )

did you try `bin/cake routes check ‘/Personas/index?page=1&sort=title’ to see how your router is handling the url?

How do I check in Routes the url that comes to him? I usually do that in the controller through a debug($page) for example;

If I put by hand the url in the browser for example:


It doesn’t go to page 5 and it doesn’t sort by name.

Instead it shows page 1 and sorts by the ID that are the default values.

You’ll need to use the console tools from the command line

and specifically these:

oohh thank you! I’m going to try

bin/cake routes check "Personas/index?page=2"

pass this empty

Try disable or comment your put line on routes…

If I comment on the line of routes it does the same, but the directions instead of creating them as:


It creates them without the index:


1 Like

The problem was in the configuration of Nginx, in:

location / {

I just had to change this line:

try_files $uri $uri/ /index.php;

for this one:

try_files $uri /index.php?$args;

and it all worked.