PHPackages                             benhall14/php-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. benhall14/php-pagination

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

benhall14/php-pagination
========================

A lightweight PHP pagination class to output pagination links.

1.2(1y ago)415.7k↓42.6%2MITPHPPHP &gt;=5.5

Since Mar 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/benhall14/php-pagination)[ Packagist](https://packagist.org/packages/benhall14/php-pagination)[ Docs](https://github.com/benhall14/php-pagination)[ RSS](/packages/benhall14-php-pagination/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

PHP Pagination
==============

[](#php-pagination)

A lightweight PHP pagination class to output pagination links.

This class is written to be chain-able so to create a logically fluent and easily readable way to create a set of pagination links.

It simplifies the paging of results and outputs Bootstrap 4 compatible navigation HTML.

It has been fully tested to work with PHP 5.5+, including **PHP 7+**

Installation via Composer
=========================

[](#installation-via-composer)

You can now install this class via composer.

```
$ composer require benhall14/php-pagination

```

**Remember** to add the composer autoloader before using the class and use the correct namespace.

```
require 'vendor/autoload.php';

use benhall14\PHPPagination\Pagination as Pagination;

```

Usage
=====

[](#usage)

Please make sure you have added the required classes.

In its simplest form, you can use the following to set up the paginator.

```
$pagination = new Pagination();
$pagination->total(100)->output();
```

You can use the following chainable methods to customise the final pagination links.

```
# sets the total number of items in the collection - e.g. 100
$pagination->total(number);

# sets the current page. By default, the class looks for the page value in the GET query string.
$pagination->page(number);

# sets the number of items to show per page. Default = 20
$pagination->perPage(number);

# sets the separator (if using). Default '...'
$pagination->separator(text);

# sets the screen reader class. Default 'true', but you may need to set it to false if you are using your own custom css.
$pagination->screenReader(bool);

# sets the Bootstrap 4 pagination link class to small
$pagination->small();

# sets the Bootstrap 4 pagination link class to medium
$pagination->medium();

# sets the Bootstrap 4 pagination link class to large
$pagination->large();

# sets the Bootstrap 4 alignment class to left
$pagination->alignLeft();

# sets the Bootstrap 4 alignment class to center
$pagination->alignCenter();

# sets the Bootstrap 4 alignment class to right
$pagination->alignRight();

# sets the flag to show the separator
$pagination->showSeparator();

# sets the flag to hide the separator
$pagination->hideSeparator();

# sets the next text string - Default: 'Next'
$pagination->nextText(text);

# sets the previous text string - Default: 'Previous'
$pagination->previousText(text);

# hides the 'Next' link
$pagination->hideNext();

# shows the 'Next' link
$pagination->showNext();

# hides the 'Previous' link
$pagination->hidePrevious();

# shows the 'Previous' link
$pagination->showPrevious();

# sets a prefix text for each page link: {prefix} {page number} {suffix}
$pagination->pagePrefix(text);

# sets a suffix text for each page link: {prefix} {page number} {suffix}
$pagination->pageSuffix(text);

# sets the flag to retain the query string for each page link.
$pagination->retainQueryString();

# sets the flag to ignore the query string when building the links
$pagination->dismissQueryString();

# sets the number of pages BEFORE the separator
$pagination->pagesBeforeSeparator(number);

# sets the number of pages AROUND the active page
$pagination->pagesAroundActive(number);

# sets the URL pattern - Default $pattern: ?page=(:num)- $replacement: (:num)
$pagination->pattern($pattern, $replacement);
# The class will replace the $replacement token in the $pattern with the actual page number
```

Requirements
============

[](#requirements)

**Works with PHP 5.5, PHP 5.6, and PHP 7+**

License
=======

[](#license)

Copyright (c) 2016-2019 Benjamin Hall,

Licensed under the MIT license

Donate?
=======

[](#donate)

If you find this project helpful or useful in any way, please consider getting me a cup of coffee - It's really appreciated :)

[![Donate](https://camo.githubusercontent.com/604e3db9c8751116b3f765aad0353ec7ded655bbe8aaacbc38d8c4a6b784b3ed/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d50617950616c2d677265656e2e737667)](https://paypal.me/benhall14)

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% 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 ~1082 days

Total

3

Last Release

516d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17323507?v=4)[Benjamin Hall](/maintainers/benhall14)[@benhall14](https://github.com/benhall14)

---

Top Contributors

[![benhall14](https://avatars.githubusercontent.com/u/17323507?v=4)](https://github.com/benhall14 "benhall14 (6 commits)")[![Anthony-Saresoft](https://avatars.githubusercontent.com/u/180268940?v=4)](https://github.com/Anthony-Saresoft "Anthony-Saresoft (2 commits)")[![kumy](https://avatars.githubusercontent.com/u/176794?v=4)](https://github.com/kumy "kumy (2 commits)")

---

Tags

bootstrap-paginationpaginationpagination-linksphpphp-paginationphppaginationpaginate

### Embed Badge

![Health badge](/badges/benhall14-php-pagination/health.svg)

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

###  Alternatives

[stefangabos/zebra_pagination

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

11923.8k](/packages/stefangabos-zebra-pagination)

PHPackages © 2026

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