PHPackages                             volnix/paginate - 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. volnix/paginate

ActiveLibrary

volnix/paginate
===============

A simple pagination library that is easily extensible for custom pagination operations.

2.0.1(8y ago)11371MITPHPPHP &gt;= 5.4

Since May 5Pushed 8y ago1 watchersCompare

[ Source](https://github.com/volnix/paginate)[ Packagist](https://packagist.org/packages/volnix/paginate)[ Docs](https://github.com/volnix/paginate)[ RSS](/packages/volnix-paginate/feed)WikiDiscussions master Synced today

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

Paginate
========

[](#paginate)

[![Build Status](https://camo.githubusercontent.com/49c9827b5ea0d43c9165f9bf782792f617e4e1b819ad6bee557f715cbf4d087d/68747470733a2f2f7472617669732d63692e6f72672f766f6c6e69782f706167696e6174652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/volnix/paginate) [![Coverage Status](https://camo.githubusercontent.com/d67e47ad2695646e54eb3977d7b23bb583ca914217a7b822c7819dfd4dad0ca2/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f766f6c6e69782f706167696e6174652f62616467652e706e67)](https://coveralls.io/r/volnix/paginate) [![Total Downloads](https://camo.githubusercontent.com/c7def5d6cb5da87563c905865cf2aaceed9a0190882051f97e4fb60a0cace233/68747470733a2f2f706f7365722e707567782e6f72672f766f6c6e69782f706167696e6174652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/volnix/paginate) [![Latest Stable Version](https://camo.githubusercontent.com/64eff92a89e428e20aabd7573764fb91ccdf9be1272d8197bb79512be2e8e991/68747470733a2f2f706f7365722e707567782e6f72672f766f6c6e69782f706167696e6174652f762f737461626c652e706e67)](https://packagist.org/packages/volnix/paginate)

Paginate is a dead-simple pagination data-model. It holds metadata about your pagination system and also the current state of pagination at any given time. It is useful for use in models for server-side pagination, views for client-side pagination building, and everywhere in between.

Basic Usage
-----------

[](#basic-usage)

The pagination library can be used with zero configuration if desired. There are 3 config settings for Paginate and are simply metadata about your pagination system:

- Results per Page (default: 50) - the number of results to display on each page
- Page Range (default: 2) - the number of pages on either side of the current page to display (e.g., if you're on page 5 it would show pages 3 through 7 in your pagination)
- Index (default: 'page') - the GET/POST index that your current page identifier is passed in on; useful when it's time to start building up pagination

Zero-configuration pagination:

```
// instantiate our pager
$pager = new \Volnix\Paginate\Pager;

// actually set the pagination parameters
$pager->paginate(1000, 5); // 100 results in result-set, current page = 5
```

> **Note:** The `paginate` method is what actually sets the current pagination state. This must be called with the result count (and optionally current page) to build up useful pagination information.

The use-case above would set the following parameters about the current state of your pagination (these correspond to class variables in the Pager):

- Number of pages ($max\_page): 20 (1000 results, 50 per page)
- Current page: 5
- Page range shown ($low\_page - $high\_page): 3 - 7 (2 page page-range)
- Query skip ($query\_skip): 400 (on page 5 with 100 results per page, so skip the first 400 since we're on 401-500)

Configuring Pagination
----------------------

[](#configuring-pagination)

You may also set the style of pagination you want by passing in metadata through the constructor or calling the `setConfig` method:

```
// both of the below examples do the exact same thing
$pager = new \Volnix\Paginate\Pager(5, 5, 'foo');

$pager = new \Volnix\Paginate\Pager;
$pager->setConfig(5, 5, 'foo');
```

> **Note:** Neither of the above examples are calling the `paginate` method. The pager is not of any value until `paginate` is called, for that method actually sets your current state.

Pagination Information
----------------------

[](#pagination-information)

The class variables exposed by the Pager are the core of the information provided by this library and are what are to be used by any extensions:

- `paginate` - A bool of whether to paginate or not
- `current_page` - The current page (passed in through the `paginate` method call.
- `query_skip` - The amount of records of skip in your ORM when querying for the next result-set
- `result_count` - The total number of results matching a given set of search criteria that need to be paged through
- `min_page` - The minimum page of pagination (always 1)
- `max_page` - The maximum page of pagination (equals the number of results / the results per page)
- `low_page` - The low range of pages to display (determined by `$page_range`)
- `high_page` - The high range of pages to display

```
public $paginate				= true; // whether to even paginate or not
public $current_page			= 1; // current page
public $query_skip				= 0; // the skip step to be passed into queries
public $result_count			= 0; // how many results we're paginating
public $min_page				= 1; // min page of all pages
public $max_page				= 1; // max page (i.e. results / results per page)
public $low_page				= 1; // low page in range of pages being displayed
public $high_page				= 1; // high page in range of pages being displayed
```

Method Chaining
---------------

[](#method-chaining)

The `paginate` and `setConfig` methods both return the Pager object, so method-chaining is possible:

```
$pager = new \Volnix\Paginate\Pager;
$pager->setConfig(5, 5, 'foo')->paginate(100);

// OR

$pager = (new \Volnix\Paginate\Pager)->setConfig(5, 5, 'foo')->paginate(100);
```

API Pagination
--------------

[](#api-pagination)

Paginate can return an array or JSON containing pertinent information for API pagination. These fields are returned in both formats:

- `current`: the current page
- `prev`: the previous page (equal to the minimum page if at the low end of pagination)
- `next`: the next page (equal to the maximum page if at the upper end of pagination)
- `skip`: the query skip
- `min`: the minimum page
- `max`: the maxmimum page

> **Note:** `prev` and `next` will both be equal to 1 if there is no pagination

Extending Paginate
------------------

[](#extending-paginate)

This library is meant to be extended. Once you have your basic pagination information, it is possible to build up server-side, client-side, etc. pagination in whatever ORM or javascript library you use in your project.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~285 days

Total

5

Last Release

3248d ago

Major Versions

1.2 → 2.02014-05-07

### Community

Maintainers

![](https://www.gravatar.com/avatar/cf948f50a689332d2ef7bafa6265a83fea2dbd2c4f18453585fbc64cffa716b6?d=identicon)[volnix](/maintainers/volnix)

---

Top Contributors

[![volnix](https://avatars.githubusercontent.com/u/1538220?v=4)](https://github.com/volnix "volnix (11 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/volnix-paginate/health.svg)

```
[![Health](https://phpackages.com/badges/volnix-paginate/health.svg)](https://phpackages.com/packages/volnix-paginate)
```

###  Alternatives

[codeclimate/php-test-reporter

PHP client for reporting test coverage to Code Climate

651.7M1.3k](/packages/codeclimate-php-test-reporter)[andrejsstepanovs/business-days-calculator

Business day calculation

2361.9k](/packages/andrejsstepanovs-business-days-calculator)[andsalves/doctrine-elastic

Elasticsearch Doctrine Adaptation

156.6k](/packages/andsalves-doctrine-elastic)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
