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

Abandoned → [valksor/php-functions-pagination](/?search=valksor%2Fphp-functions-pagination)Library[Utility &amp; Helpers](/categories/utility)

vairogs/functions-pagination
============================

A PHP library providing pagination functionality to generate page numbers for UI pagination controls, with smart handling of large page sets

00PHP

Since Apr 16Pushed 11mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Vairogs Functions: Pagination
=============================

[](#vairogs-functions-pagination)

A PHP library providing pagination functionality to generate page numbers for UI pagination controls, with smart handling of large page sets.

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

[](#installation)

Install the package via Composer:

```
composer require vairogs/functions-pagination
```

Requirements
------------

[](#requirements)

PHP 8.4 or higher

Usage
-----

[](#usage)

The Pagination class provides a mechanism to generate pagination data for displaying page numbers in a UI, with intelligent handling of omitted pages.

### Basic Usage

[](#basic-usage)

```
use Vairogs\Functions\Pagination\Pagination;

// Create a new Pagination instance
$pagination = new Pagination();

// Generate pagination data
$pages = $pagination->paginate(
    7,       // Number of visible pages
    20,      // Total number of pages
    5,       // Current page
    -1       // Indicator for omitted pages (optional, defaults to -1)
);

// $pages will contain an array like: [1, 2, 3, 4, 5, 6, 7, -1, 20]
// where -1 represents omitted pages
```

### Different Pagination Scenarios

[](#different-pagination-scenarios)

The pagination algorithm intelligently handles different scenarios:

#### All Pages Visible

[](#all-pages-visible)

When the total number of pages is less than or equal to the number of visible pages:

```
$pages = $pagination->paginate(10, 8, 4); // [1, 2, 3, 4, 5, 6, 7, 8]
```

#### Single Omitted Section

[](#single-omitted-section)

When the current page is near the beginning or end:

```
// Current page near beginning
$pages = $pagination->paginate(7, 20, 3); // [1, 2, 3, 4, 5, -1, 20]

// Current page near end
$pages = $pagination->paginate(7, 20, 18); // [1, -1, 16, 17, 18, 19, 20]
```

#### Two Omitted Sections

[](#two-omitted-sections)

When the current page is in the middle of a large set:

```
$pages = $pagination->paginate(7, 20, 10); // [1, -1, 8, 9, 10, 11, 12, -1, 20]
```

Features
--------

[](#features)

For a complete list of all functions available in this package, see [Features](docs/features.md).

Validation
----------

[](#validation)

The class performs several validations:

- The number of visible pages must be at least 5
- The total number of pages must be at least 1
- The current page must be between 1 and the total number of pages
- The indicator value must not be a valid page number (between 1 and total)

License
-------

[](#license)

This package is licensed under the [BSD-3-Clause License](LICENSE).

About Vairogs
-------------

[](#about-vairogs)

This package is part of the [vairogs/vairogs](https://github.com/vairogs/vairogs) project - a comprehensive PHP library and Symfony bundle that provides a collection of utilities, components, and integrations for Symfony applications.

The main project includes:

- Various utility functions and components
- Doctrine ORM tools and extensions
- API Platform integrations
- Symfony bundle for easy configuration
- And much more

If you find this Pagination component useful, you might want to check out the full Vairogs project for additional tools and utilities that can enhance your Symfony application development.

To install the complete package:

```
composer require vairogs/vairogs
```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c4db85e32518c5a6caa2fd625032a2b016ef42d60cf8a101c165cc5c0048b221?d=identicon)[k0d3r1s](/maintainers/k0d3r1s)

---

Top Contributors

[![k0d3r1s](https://avatars.githubusercontent.com/u/38725938?v=4)](https://github.com/k0d3r1s "k0d3r1s (2 commits)")

### Embed Badge

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

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

PHPackages © 2026

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