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

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

paginator/paginator
===================

Paginator

v1.0(7y ago)37572MITPHPPHP &gt;=7.1CI failing

Since Sep 24Pushed 6y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (1)Versions (9)Used By (0)

Paginator
=========

[](#paginator)

A powerful PHP pagination engine to take care of pagination hassles

[![Build Status](https://camo.githubusercontent.com/f61d6e734980832ed49dcaf1cc4aaade9a82aea48c38a64d23641a8ec14a360f/68747470733a2f2f7472617669732d63692e6f72672f6972616e69616e7065702f706167696e61746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/iranianpep/paginator)[![Maintainability](https://camo.githubusercontent.com/a01e10567116878f31173c2901510e283b4d6e3365f119b4dfd1c189101ba1e8/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f39663862326464313562663361386634383130332f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/iranianpep/paginator/maintainability)[![Test Coverage](https://camo.githubusercontent.com/b6258b43493c0dfd20a2dd09a2c26230f16e9d2e54ff668d81ab474a51c4c76b/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f39663862326464313562663361386634383130332f746573745f636f766572616765)](https://codeclimate.com/github/iranianpep/paginator/test_coverage)[![StyleCI](https://camo.githubusercontent.com/69c0ca0085475c91352412979f14aba5e057cd423e07252c429894c7dd1c5927/68747470733a2f2f7374796c6563692e696f2f7265706f732f3134393536373035342f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/149567054)[![Issue Count](https://camo.githubusercontent.com/cbde4abb6adac1bc71db28c71f15b34e7cf7117e46213d472c482b768de3a105/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6972616e69616e7065702f706167696e61746f722f6261646765732f69737375655f636f756e742e737667)](https://codeclimate.com/github/iranianpep/paginator)[![Codacy Badge](https://camo.githubusercontent.com/05f4aed5dd0545fd4141e33444136a98375425fa69eacf390b6b33bd988bc08f/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3134333836313438343935363463373661633937653465656663636565363364)](https://www.codacy.com/app/iranianpep/paginator?utm_source=github.com&utm_medium=referral&utm_content=iranianpep/paginator&utm_campaign=Badge_Grade)

Server Requirements
-------------------

[](#server-requirements)

- PHP &gt;= 7.1

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

[](#installation)

- Using Composer get the latest version:

```
composer require paginator/paginator

```

Example
-------

[](#example)

The simplest way to use Paginator is as follow:

```
$totalItems = 3;
$perPage = 1;
$currentPage = 1;
$url = 'https://example.com';

$paginator = new Paginator($totalItems, $perPage, $currentPage, $url);

if ($paginator->hasPages() === true) {
    if ($paginator->getPreviousPage()) {
        $previousPageUrl = $paginator->getPreviousPageUrl();

        echo "Previous";
    }

    foreach ($paginator->getPages() as $page) {
        if (!$page instanceof Page) {
            continue;
        }

        $pageNumber = $page->getNumber();
        $pageUrl = $page->getUrl();
        $cssClass = $page->isCurrent() === true ? 'active' : '';

        echo "{$pageNumber}";
    }

    if ($paginator->getNextPage()) {
        $nextPageUrl = $paginator->getNextPageUrl();

        echo "Next";
    }
}

```

If you are using any MVC framework like Laravel instantiate an object from Paginator class in the controller and pass it to the view:

#### Controller

[](#controller)

```
public function index(Request $request)
{
    $totalProductsNumber = 10;
    $perPage = 10;
    $currentPageNumber = (int) $request->get('page') > 0 ? $request->get('page') : 1;
    $url = $request->fullUrl();

    $paginator = new Paginator($totalProductsNumber, $perPage, $currentPageNumber, $url);

    // you should use the offset in your database query to get a slice of data
    $offset = $paginator->calculateDatabaseOffset($currentPageNumber);

    return view('view.index', [
        'paginator' => $paginator
    ]);
}

```

#### View (Laravel Blade)

[](#view-laravel-blade)

```
@if ($paginator->hasPages())

        @if ($paginator->isOnFirstPage() === true)
            &laquo;
        @else
            &laquo;
        @endif

        @php
            $hiddenRanges = $paginator->getHiddenRanges();
        @endphp

        @foreach ($paginator->getPages() as $page)
            {{-- "Three Dots" Separator --}}
            @if ((isset($hiddenRanges[0]) && $page->getNumber() === $hiddenRanges[0]['start']) ||
            (isset($hiddenRanges[1]) && $page->getNumber() === $hiddenRanges[1]['start']))
                ...
            @elseif((isset($hiddenRanges[0]) && $page->getNumber() > $hiddenRanges[0]['start'] && $page->getNumber() getNumber() > $hiddenRanges[1]['start'] && $page->getNumber() isCurrent())
                    {{ $page->getNumber() }}
                @else
                    {{ $page->getNumber() }}
                @endif
            @endif
        @endforeach

        @if ($paginator->isOnLastPage() === false)
            &raquo;
        @else
            &raquo;
        @endif

@endif

```

###  Health Score

31

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 98.6% 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

2877d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c4e337f9891a92e469bd236f9774b8c6a894b05a31fc4f3d2da1f4010977b44e?d=identicon)[ehsan.abb](/maintainers/ehsan.abb)

---

Top Contributors

[![iranianpep](https://avatars.githubusercontent.com/u/3667439?v=4)](https://github.com/iranianpep "iranianpep (71 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

pagepaginablepaginationpagination-generatorpagination-librarypaginatorpaging

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[michael-rubel/laravel-enhanced-pipeline

Laravel Pipeline with DB transaction support, events and additional methods.

5522.7k](/packages/michael-rubel-laravel-enhanced-pipeline)[t3docs/examples

This extension packages a number of code examples from the Core Documentation.

3521.7k](/packages/t3docs-examples)[cyrkulewski/shopping-cart

Simple ZF2 Shopping Cart

192.1k](/packages/cyrkulewski-shopping-cart)

PHPackages © 2026

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