CakePHP provides a core Pagination component to process the request parameters in the controller and build the model queries to retrieve paginated data. Instead of getting all the rows from your table, based on the current request parameters, the Pagination component will retrieve only the current page, defined as a limited amount of rows. Of course, all of the pagination settings can be configured, such as to define a specific page limit or change the default ordering of the paginated data.
Just after creating your initial CRUD for any database table, you'll get a fully paginated index view. In this recipe, we'll tweak the pagination defaults to use some URL query string parameters instead of named parameters (named params are deprecated in CakePHP 3.0).
You'll identify named parameters when your website's URL looks something like the following:
Query string parameters will generate a URL, which instead looks like this: