PHPackages                             sebastiansulinski/php-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. sebastiansulinski/php-paginator

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

sebastiansulinski/php-paginator
===============================

Framework agnostic PHP Pagination component

v3.2.1(7mo ago)320.6k↓100%MITPHPPHP ^8.3CI failing

Since Oct 12Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/sebastiansulinski/php-paginator)[ Packagist](https://packagist.org/packages/sebastiansulinski/php-paginator)[ RSS](/packages/sebastiansulinski-php-paginator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (26)Used By (0)

Framework agnostic PHP Pagination component
===========================================

[](#framework-agnostic-php-pagination-component)

Light weight, easy drop-in pagination component for PHP 8 applications.

### Installation

[](#installation)

```
composer require sebastiansulinski/php-paginator

```

### Structure

[](#structure)

The component consist of 2 main classes:

- `Pagination` - class, to which you pass

    - instance of a `SSD\Paginator\Request` or, if your project already makes use of `\Illuminate\Http\Request`, you can pass instance of it instead.
    - total number of records
    - number of records per page
    - string key representing the query string parameter associated with the current page
- `Paginator` - a parent class for any implementations that return the html structure of a pagination. Its constructor takes 2 arguments:

    - instance of `Pagination`
    - records for a given page as instance of `SSD\Paginator\Collection` or `Illuminate\Support\Collection`

Package comes with one implementation of `Paginator`:

#### VueSelectPaginator

[](#vueselectpaginator)

The `VueSelectPaginator` returns the following structure when `render()` method is called on its instance (all entities are decoded for clarity):

```

```

And to support this implementation, there is a `VueJs` component that ships with this package - you'll find it under `resources/src/js/components/SsdPaginator`:

```
import { createApp } from 'vue'
import SsdPaginator from './components/SsdPaginator'

createApp({
  components: { SsdPaginator },
}).mount('#app')
```

To create your own implementations of `Paginator` all you have to do is to provide implementation of the `html()` method, which should return the html structure of your pagination layout.

### Styling

[](#styling)

SsdPaginator comes pre-formatted using tailwindcss v3, but you can replace its structure using the available slot and apply your own styling as required.

### Usage

[](#usage)

```
// import all dependencies

use SSD\Paginator\Request;
use SSD\Paginator\Collection;
use SSD\Paginator\Pagination;
use SSD\Paginator\VueSelectPaginator;

// instantiate Pagination class

$pagination = new Pagination(
    Request::capture(),
    160,
    10,
    'page'
);

// get your records as array and pass through to the Collection
// in this example I just use array of numbers and get only a chunk
// of records based on offset and limit, but you'd probably use
// some active model to get only the records you're after

$records = range(1, 160);
$records = new Collection($records);

$chunk = $records->splice(
    $pagination->offset(),
    $pagination->limit()
);

// instantiate SelectPaginator with instance of Pagination and collection of records

$paginator = new VueSelectPaginator($pagination, $chunk);
```

### Displaying records and pagination

[](#displaying-records-and-pagination)

```
// loop through records using Collection::map() and implode() methods

echo $paginator->records()->map(function($record) {
    // ...
})->implode('');

// or using standard foreach loop

foreach($paginator->records() as $record) {
    // ...
}

// display pagination

echo $paginator->render();
```

### Custom pagination structure

[](#custom-pagination-structure)

If you don't want to use `Paginator` class implementation, the `Pagination` class has all necessary methods to allow you put together pagination structure directly in your view, for instance to display list of all pages as clickable numbers with current page highlighted using `class="active"`, you could do something like:

```
$pagination = new Pagination(
    Request::capture(),
    160,
    10,
    'page'
);

echo '';

echo $pagination->urlList()->map(function(string $url, int $page) use($pagination) {
    $link  = ''.$page.'';
    return $link;
})->implode('');

echo '';
```

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance67

Regular maintenance activity

Popularity28

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity88

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 63.2% 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 ~121 days

Recently: every ~330 days

Total

25

Last Release

226d ago

Major Versions

v1.2.3 → v2.0.02019-08-26

v2.2.7 → 3.0.02022-02-10

PHP version history (10 changes)v1.0.0PHP &gt;=7.1.0

v1.1.0PHP &gt;=7.0.0

v1.2.0PHP ^7.1

v2.0.0PHP ^7.2

v2.1.0PHP ^7.2.5

v2.2.0PHP ^7.3

v2.2.3PHP ^7.3 || ^8.0

3.0.0PHP ^8.0

v3.1.0PHP ^8.1

v3.2.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2211203?v=4)[Sebastian Sulinski](/maintainers/sebastiansulinski)[@sebastiansulinski](https://github.com/sebastiansulinski)

---

Top Contributors

[![sebastiansulinski](https://avatars.githubusercontent.com/u/2211203?v=4)](https://github.com/sebastiansulinski "sebastiansulinski (24 commits)")[![ssdtutorials](https://avatars.githubusercontent.com/u/18402239?v=4)](https://github.com/ssdtutorials "ssdtutorials (14 commits)")

---

Tags

paginatepaginate-arraypaginate-collectionpaginated-postspaginationpaginatorphp-pagination

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[watson/active

Laravel helper for recognising the current route, controller and action

3253.6M14](/packages/watson-active)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[beyondcode/laravel-favicon

Create dynamic favicons based on your environment settings.

37345.5k](/packages/beyondcode-laravel-favicon)[glhd/conveyor-belt

14797.0k](/packages/glhd-conveyor-belt)[dragon-code/pretty-routes

Pretty Routes for Laravel

10058.7k4](/packages/dragon-code-pretty-routes)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40129.3k2](/packages/erlandmuchasaj-laravel-gzip)

PHPackages © 2026

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