When you need to paginate data, you can use the [hyperf/paginator](https://github.com/hyperf/paginator) component to solve your problem conveniently. You can encapsulate your data query little bit to perform better pagination. This component can also works well on other frameworks.
In most cases, paginator is used when query from databases. [hyperf/database](https://github.com/hyperf/database) component has already adapted the paginator component. You can easily use the paginator during data query. More details in [Database - Paginator](en/db/paginator.md) chapter.
As long as there are data sets and paging requirements, you can instantiate a `Hyperf\Paginator\Paginator` class for paging processing. The constructor of this class receives `__construct($items, int $perPage, ?int $currentPage = null, array $options = [])` parameters. Just pass the data set to the `$items` parameter in the form of `Array (Array)` or `Hyperf\Utils\Colletion` collection class, and set the amount of data per page `$perPage` and the current page number `$currentPage `. The `$options` parameter can define all the attributes of the paginator instance in the form of `Key-Value`, and you can refer to the internal attributes of the paginator class for more details.