PHPackages                             ucscode/easy-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. ucscode/easy-paginator

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

ucscode/easy-paginator
======================

A lightweight and flexible PHP pagination library for handling paginated data and generating pagination links.

2.0.1(1y ago)01281MITPHPPHP &gt;=8.2

Since Feb 19Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ucscode/easy-paginator)[ Packagist](https://packagist.org/packages/ucscode/easy-paginator)[ Docs](http://github.com/ucscode/easy-paginator)[ RSS](/packages/ucscode-easy-paginator/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependencies (2)Versions (6)Used By (1)

Easy Paginator
==============

[](#easy-paginator)

Ucscode Paginator is a lightweight PHP pagination library designed to handle paginated data efficiently. It provides an easy-to-use interface for managing and generating pagination links.

This project requires a minimum of PHP 8.2

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

[](#installation)

Install the package via Composer:

```
composer require ucscode/easy-paginator
```

Usage
-----

[](#usage)

### Creating a Paginator

[](#creating-a-paginator)

```
use Ucscode\Paginator\Paginator;

$paginator = new Paginator(
    totalItems: 100,       // Total number of items
    itemsPerPage: 10,      // Items per page
    currentPage: 3,        // Current page
    urlPattern: '?page=(:num)' // URL pattern with placeholder
);
```

### Getting Pagination Information

[](#getting-pagination-information)

```
$paginator->getTotalPages();   // Total number of pages
$paginator->getCurrentPage();  // Current page number
$paginator->getNextPage();     // Next page number or null if last page
$paginator->getPrevPage();     // Previous page number or null if first page
```

### Generating URLs

[](#generating-urls)

```
$paginator->getPageUrl(5); // Returns '?page=5'
$paginator->getNextUrl();  // URL for the next page
$paginator->getPrevUrl();  // URL for the previous page
```

Pagination Builder
------------------

[](#pagination-builder)

The `Builder` class generates an array of `Item`, which can be iterated to display page links.

### Example

[](#example)

```
$builder = $paginator->getBuilder();

$builder->getPrevItem(); // Item|null

foreach ($builder->getItems() as $item) {
    echo

                {$item->getContent()}

    HTML;
}

$builder->getNextItem(); // Item|null
```

### Pagination Items

[](#pagination-items)

The `Builder::getItems()` generates an array of `Item`:

```
[
    new Item(),
    new Item(),
    new Item(),
]
```

Where an `Item` contains getters and setters for the following properties:

```
class Item {
    protected ?string $url = null;
    protected bool $active = false;
    protected int $pageNumber = 0;
    protected string|NodeInterface $content = '';
}
```

---

For structured HTML generation, use can still use the `Builder`. This class converts pagination data into an HTML structure with `ul` and `li` elements, making it easy to integrate into any UI.

### Example Usage

[](#example-usage)

```
$builder = $paginator->getBuilder();

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

The will generate HTML similar to bootstrap 5 pagination:

```

            &laquo;

            1

            2

            3

            &raquo;

```

### Updating the HTML Element

[](#updating-the-html-element)

You can customize the HTML Element before rendering it by taking advantage of the [UssElement Library](https://github.com/ucscode/uss-element).

```
$navElement = $builder->createElement();

$navElement->getClassList()->add('my-nav-class');
$navElement->setAttribute('data-name', 'pagination');

$ulElement = $navElement->querySelector('ul.pagination');

$ulElement->setAttribute('id', 'nav-id')
```

Checkout [UssELement](https://github.com/ucscode/uss-element) and read the official documentation for more details

Acknowledgement
---------------

[](#acknowledgement)

Inspired by [jasongrimes/php-paginator](https://github.com/jasongrimes/php-paginator/tree/master)

Licence
-------

[](#licence)

Easy Paginator is licensed under the [MIT License](./LICENSE).

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance41

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity54

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

Every ~2 days

Total

5

Last Release

491d ago

Major Versions

1.1.1 → 2.0.02025-02-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/65673b1b31e87471999a7614d107e7e061a38bf72191d149c66c1b943124e09c?d=identicon)[ucscode](/maintainers/ucscode)

---

Top Contributors

[![ucscode](https://avatars.githubusercontent.com/u/34024404?v=4)](https://github.com/ucscode "ucscode (9 commits)")

---

Tags

pagerpaginatorpagination

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  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)[ashleydawson/simple-pagination

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

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

The most thin, simple and customizable paginator bundle for Symfony

1115.2k](/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)
