PHPackages                             fastpress/paginator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. fastpress/paginator

ActiveLibrary[Framework](/categories/framework)

fastpress/paginator
===================

Pagination library for FastPress applications

0.1.0(1y ago)08MITPHPPHP &gt;=7.4

Since Oct 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/fastpress/paginator)[ Packagist](https://packagist.org/packages/fastpress/paginator)[ Docs](https://github.com/fastpress/paginator)[ RSS](/packages/fastpress-paginator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Paginator
=========

[](#paginator)

A PHP Pagination Library

The Paginator class provides a simple and efficient way to implement pagination in your PHP applications. It handles the calculation of page numbers, total records, and other related information, making it easy to create paginated interfaces.

Installation
------------

[](#installation)

To use the Paginator library, you can install it using Composer:

```
composer require fastpress/pagination
```

Usage
-----

[](#usage)

Create a new Paginator instance:

```
use Fastpress\Pagination\Paginator;

$paginator = new Paginator(100, 3, 10);
// 100: Total number of records.
// 3: Current page number.
// 10: Records per page limit.
```

Get pagination data:

```
php
$paginationData = $paginator->getPaginationData();

```

The $paginationData array will contain the following information:

- current\_page\_number: The current page number.
- total\_records: The total number of records.
- total\_records\_remaining: The number of remaining records.
- total\_pages: The total number of pages.
- limit: The records per page limit.
- has\_next\_page: Whether there is a next page.
- has\_prev\_page: Whether there is a previous page.
- next\_page: The next page number (if available).
- previous\_page: The previous page number (if available).
- display\_pages: An array of page numbers to display in the pagination controls.

Example
-------

[](#example)

```
