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 3w 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 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

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

1957d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/45949485?v=4)[zkwbbr](/maintainers/zkwbbr)[@zkwbbr](https://github.com/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

[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.

4091.3M22](/packages/jasongrimes-paginator)[coffeecode/paginator

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

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

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

163643.5k14](/packages/beberlei-porpaginas)[stefangabos/zebra_pagination

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

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

Rapid pagination for Laravel

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

Rapid pagination without using OFFSET

3780.1k6](/packages/lampager-lampager)

PHPackages © 2026

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