PHPackages                             sirprize/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. sirprize/paginate

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

sirprize/paginate
=================

Normalize an index range from user input

2.0.0(3y ago)1387MITPHPPHP ^7.2 || ^8.0CI failing

Since May 10Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/sirprize/paginate)[ Packagist](https://packagist.org/packages/sirprize/paginate)[ Docs](https://github.com/sirprize/paginate)[ RSS](/packages/sirprize-paginate/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

Paginate
========

[](#paginate)

Normalize an index range from user input

Use Case 1 (start with an index range)
--------------------------------------

[](#use-case-1-start-with-an-index-range)

1. Get the current range from user input (eg from a HTTP header - `Range: items=40-49`)
2. Define the slice (eg run a query with a `LIMIT` expression)

### Usage

[](#usage)

```
use Sirprize\Paginate\Input\IndexInput;
use Sirprize\Paginate\Range\IndexRange;

$i = new IndexInput(4400, 4499); // $offset, $last
$i->setDefaultNumItems(25)->setMaxItems(100); // set defaults and limits
$r = new IndexRange($i);
$q = sprintf("SELECT * FROM my_table LIMIT %d, %d", $r->getOffset(), $r->getNumItems());

```

Use Case 2 (start from current page)
------------------------------------

[](#use-case-2-start-from-current-page)

1. Get the current page and possibly the number of items per page from user input
2. Define the slice (eg run a query with a `LIMIT` expression)

### Usage

[](#usage-1)

```
use Sirprize\Paginate\Input\PageInput;
use Sirprize\Paginate\Range\PageRange;

$i = new PageInput(45, 100); // $currentPage, $numItemsPerPage
$i->setDefaultNumItems(25)->setMaxItems(100); // set defaults and limits
$r = new PageRange($i);
$q = sprintf("SELECT * FROM my_table LIMIT %d, %d", $r->getOffset(), $r->getNumItems());

```

Paginator
---------

[](#paginator)

1. Perform an action to get the total number of items in a list (eg run a simple query with a `COUNT` expression)
2. Get the current page and possibly the number of items per page from user input
3. Start paginator with user input and number of items
4. Define the slice (eg run a complex query with a `LIMIT` expression)

### Usage

[](#usage-2)

```
use Sirprize\Paginate\Input\PageInput;
use Sirprize\Paginate\Range\PageRange;
use Sirprize\Paginate\Paginator;

$i = new PageInput(45, 100); // $currentPage, $numItemsPerPage
$i->setDefaultNumItems(25)->setMaxItems(100); // set defaults and limits
$r = new PageRange($i);
$r->setTotalItems(189678);
$p = new Paginator($r);
$p->setBaseUrl('/products')
$p->setPageParam('p');

```

### The following information is available:

[](#the-following-information-is-available)

```
echo $p->isOutOfBounds(); // 0
echo $p->getTotalItems(); // 189678
echo $p->getNumItemsPerPage(); // 100
echo $p->getNumItemsOnCurrentPage(); // 100
echo $p->getFirstItemOnCurrentPage(); // 4401
echo $p->getLastItemOnCurrentPage(); // 4500
echo $p->getNumPages(); // 1897
echo $p->getCurrentPage(); // 45
echo $p->getPreviousPage(); // 44
echo $p->getNextPage(); // 46
echo $p->getFirstPage(); // 1
echo $p->getLastPage(); // 1897
echo $p->getOffset(); // 4400
echo $p->getLast(); // 4499
echo $p->getCurrentPageUrl(); // /products?p=45
echo $p->getNextPageUrl(); // /products?p=46
echo $p->getPreviousPageUrl(); // /products?p=44
echo $p->getFirstPageUrl(); // /products?p=1
echo $p->getLastPageUrl(); // /products?p=1897
echo $p->getBaseUrl(); // /products
echo $p->getPageParam(); // p

```

License
-------

[](#license)

See LICENSE.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance49

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity72

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 ~787 days

Recently: every ~728 days

Total

6

Last Release

1273d ago

Major Versions

v0.2.0 → 1.0.02018-09-02

1.1.1 → 2.0.02023-02-18

PHP version history (2 changes)v0.1.0PHP &gt;=5.3.2

2.0.0PHP ^7.2 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/81617?v=4)[Christian Högl](/maintainers/sirprize)[@sirprize](https://github.com/sirprize)

---

Top Contributors

[![sirprize](https://avatars.githubusercontent.com/u/81617?v=4)](https://github.com/sirprize "sirprize (20 commits)")

---

Tags

pagerpaginatorpagination

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[jasongrimes/paginator

A lightweight PHP paginator, for generating pagination controls in the style of Stack Overflow and Flickr. The 'first' and 'last' page links are shown inline as page numbers, and excess page numbers are replaced by ellipses.

4071.3M22](/packages/jasongrimes-paginator)[ashleydawson/simple-pagination

Simple, lightweight and universal service that implements pagination on collections of things

18163.2k2](/packages/ashleydawson-simple-pagination)[ttskch/paginator-bundle

The most thin, simple and customizable paginator bundle for Symfony

1115.8k](/packages/ttskch-paginator-bundle)[sivka/paginator

bootstrap-4 fork of jasongrimes/php-paginator, a lightweight PHP paginator, for generating pagination controls in the style of Stack Overflow and Flickr. The 'first' and 'last' page links are shown inline as page numbers, and excess page numbers are replaced by ellipses.

141.4k](/packages/sivka-paginator)

PHPackages © 2026

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