PHPackages                             metarush/pagination - 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. metarush/pagination

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

metarush/pagination
===================

Standalone pagination module that is not tied to any frameworks

v1.0.0(5y ago)164MITPHPPHP &gt;=7.4

Since Feb 22Pushed 5y ago1 watchersCompare

[ Source](https://github.com/metarush/pagination)[ Packagist](https://packagist.org/packages/metarush/pagination)[ RSS](/packages/metarush-pagination/feed)WikiDiscussions master Synced 1w ago

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

metarush/pagination
===================

[](#metarushpagination)

Standalone pagination module that is not tied to any frameworks

Install
-------

[](#install)

Install via composer as `metarush/pagination`

Sample usage
------------

[](#sample-usage)

```
use MetaRush\Pagination\Builder;

// define minimum required vars

$currentPage = $_GET['page'] ? (int) $_GET['page'] : 1;
$path = '/demo.php?page=';
$totalItems = 50;
$itemsPerPage = 5;
```

### Default config

[](#default-config)

```
$p = (new Builder)
    ->setTotalItems($totalItems)
    ->setItemsPerPage($itemsPerPage)
    ->setCurrentPage($currentPage)
    ->setPath($path)
    ->build();
```

Display:

```
echo $p->prevLink() . ' ' . $p->pageLinksUncut() . ' ' . $p->nextLink();
```

[![default config screenshot](public/screenshots/default-config.png?raw=true)](public/screenshots/default-config.png?raw=true)

### Display as dropdown

[](#display-as-dropdown)

Remove `->build();` from previous example then append the ff.

```
    ->setPageLink('{{page}}')
    ->setActiveLink('{{page}}')
    ->build();
```

Note: You need the ff. sample Javascript code for the dropdown to work

```

    document.getElementById('myDropdown').addEventListener('change', (event) => {
        location.href = `${event.target.value}`;
    });

```

Display:

```
echo $p->prevLink() . ' ' . $p->pageLinksUncut() . ' ' . $p->nextLink();
```

[![display as dropdown screenshot](public/screenshots/display-as-dropdown.png?raw=true)](public/screenshots/display-as-dropdown.png?raw=true)

### Auto-cut pagination

[](#auto-cut-pagination)

Remove `->setPageLink()`, `->setActiveLink()`, and `->build();` from previous example then append the ff.

```
    ->setPagesCutoff(5) // Estimated max number of page links to display (default: 7)
    ->build();
```

Display:

```
echo $p->prevLink() . ' ' . $p->pageLinksAutoCut() . ' ' . $p->nextLink();
```

[![auto-cut pagination screenshot](public/screenshots/auto-cut-pagination.png?raw=true)](public/screenshots/auto-cut-pagination.png?raw=true)

### Custom look

[](#custom-look)

Use custom HTML/CSS or frameworks like Bootstrap/Materialize/etc.

Remove `->build();` from previous example then append the ff.

```
    ->setPageLink('{{page}}')
    ->setActiveLink('{{page}}')
    ->setDisabledPrevLink('Prev')
    ->setDisabledNextLink('Next')
    ->setEllipsis('...')
    ->setPrevLink('Prev')
    ->setNextLink('Next')
    ->build();
```

Display:

```
echo '' . $p->prevLink() . ' ' . $p->pageLinksAutoCut() . ' ' . $p->nextLink().' ';
```

[![custom look screenshot](public/screenshots/custom-look.png?raw=true)](public/screenshots/custom-look.png?raw=true)

Querying data from database
---------------------------

[](#querying-data-from-database)

Code for querying of data from a database is intentionally not included in this module. This is best implemented in userland. Below are examples on how to do this:

First, determine `$limit` and `$offset`

```
$limit = $itemsPerPage;
$offset = ($itemsPerPage * $currentPage) - $itemsPerPage;
```

### Raw SQL

[](#raw-sql)

```
$sql = "SELECT * FROM your_table LIMIT $limit OFFSET $offset";
```

### Laravel query builder

[](#laravel-query-builder)

```
$result = DB::table('your_table')
            ->offset($offset)
            ->limit($limit)
            ->get();
```

### Doctrine DBAL query builder

[](#doctrine-dbal-query-builder)

```
$queryBuilder
    ->select('*')
    ->from('your_table')
    ->setFirstResult($offset)
    ->setMaxResults($limit);
```

Working demo
------------

[](#working-demo)

Check the demo in `public/demo.php`

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1911d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2efbbec5345d184bd2ffcb1c78f050fd7775cf1e52e64ab171e5673aaefc6daf?d=identicon)[zkwbbr](/maintainers/zkwbbr)

---

Top Contributors

[![zkwbbr](https://avatars.githubusercontent.com/u/45949485?v=4)](https://github.com/zkwbbr "zkwbbr (1 commits)")

---

Tags

paginatorpagination

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/metarush-pagination/health.svg)

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

###  Alternatives

[coffeecode/paginator

Paginator is simple and is ready to generate results navigation in your application

59658.1k1](/packages/coffeecode-paginator)[beberlei/porpaginas

Library that generically solves several pagination issues with DAO/repository abstractions.

163612.6k11](/packages/beberlei-porpaginas)[stefangabos/zebra_pagination

A generic, Twitter Bootstrap compatible, PHP pagination library that automatically generates navigation links

11122.9k](/packages/stefangabos-zebra-pagination)[lampager/lampager-laravel

Rapid pagination for Laravel

7641.4k](/packages/lampager-lampager-laravel)[lampager/lampager

Rapid pagination without using OFFSET

3778.3k5](/packages/lampager-lampager)[ashleydawson/simple-pagination

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

18161.2k2](/packages/ashleydawson-simple-pagination)

PHPackages © 2026

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