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

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

peterujah/pagination
====================

Pagination - Simple PHP library to generate website pagination

1.7(2y ago)268MITPHPPHP ^7.0 || ^8.0

Since Dec 21Pushed 2y ago2 watchersCompare

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

READMEChangelog (7)DependenciesVersions (7)Used By (0)

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

[](#php-pagination)

Pagination is a simple package that can generate HTML to navigate between listing pages.

It takes as parameter values the type of navigation to generate and the total number of entries in the listing.

The class generates HTML with links to allow the user to click and go to the other listing pages considering the current listing page number.

The class's navigation can be either a list of links or just a group of links pointing to each listing page.

Developers can configure the presentation of the navigation using custom CSS styles or bootstrap pagination.

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

[](#installation)

Installation is super-easy via Composer:

```
composer require peterujah/pagination
```

USAGES
======

[](#usages)

Pagination can be used as an HTML hyperlink or HTML unordered list

```
 use Peterujah\NanoBlock\Pagination;
 $paging = new Pagination($rowCount, Pagination::LIST);
 $paging = new Pagination($rowCount, Pagination::LINK);
```

Dump array

```
 $paging = new Pagination(100, Pagination::LIST);
 $paging->setLimit(20);
 $paging->setCurrentPage($_GET["page"]??1)->show();
```

```
 $paging = new Pagination(100, Pagination::LIST);
 $paging->setLimit(20);
 $html = $paging->setCurrentPage($_GET["page"]??1)->get();
```

Use built-in css style, only work with `$paging->show()` method

```
$paging->setAllowCss(true);
```

Constants
---------

[](#constants)

Initalisation options `new Pagination($rowCount, Pagination::LINK)`

OptionsDescriptionLISTRetrieve result as an html unordered listLINKRetrieve result in HTML hyperlinkMethods
-------

[](#methods)

MethodDescriptionsetLimit(int)Set query row display limit per pagesetCurrentPage(int)Set current paging numberaddQuery(string, string)Add query parameter (key, value)setQueries(array)Set query parameters array(key =&gt; value)setAllowCss(bool)Enable default paging buttons stylingsetClass(string)Set a custom class name for paging list items `li`setContainerClass(string)Set a custom class name for pagination unordered list `ul`setTruncate(int)Set pagination truncate offsetgetSize() :intGet total pagination calculated cell pagesgetOffset() :intGet pagination next page start offsetget() :stringfalseshow() :voidDisplay pagination buttonsFull usage example
------------------

[](#full-usage-example)

Example: Specify the total number of rows in your table `findTotalUsers :(int)`, then select only the number of items to show per page `findUsers(startOffset, limitPerPage)`

```
use Peterujah\NanoBlock\Pagination;
// Configure page limit
$queryLimit = 30;
$queryPage = $_GET["n"]??1;
$queryStart = ($queryPage - 1) * $queryLimit;

// Query your database table
$users = (object) array(
    "users" => $conn->findUsers($queryStart, $queryLimit),
    "rowCount" => $conn->findTotalUsers()
);

// Initialize Pagination
$paging = new Pagination($users->rowCount, Pagination::LIST);
$paging->setLimit($queryLimit);
$paging->setCurrentPage($queryPage);

// Display your contents
foreach($users->users as $row){
    echo "{$row->userFullname}";
}
// Add pagination buttons
echo "";
echo $paging->get();
echo "";
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity59

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 ~171 days

Recently: every ~179 days

Total

6

Last Release

754d ago

Major Versions

0.1 → 1.32022-05-07

### Community

Maintainers

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

---

Top Contributors

[![peterujah](https://avatars.githubusercontent.com/u/16369609?v=4)](https://github.com/peterujah "peterujah (42 commits)")

---

Tags

librarypaginationpagingphp classPHP Paginationpaging classbootstrap paging

### Embed Badge

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

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

###  Alternatives

[league/iso3166

ISO 3166-1 PHP Library

69536.3M116](/packages/league-iso3166)[beberlei/porpaginas

Library that generically solves several pagination issues with DAO/repository abstractions.

163612.6k11](/packages/beberlei-porpaginas)[stefangabos/zebra_pagination

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

11122.9k](/packages/stefangabos-zebra-pagination)[sjaakp/yii2-alphapager

Page data on initial character in Yii2.

184.4k](/packages/sjaakp-yii2-alphapager)[2createstudio/carbon-pagination

A handy WordPress library for building all kinds of paginations.

152.4k](/packages/2createstudio-carbon-pagination)

PHPackages © 2026

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