PHPackages                             tjweldon/pages - 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. tjweldon/pages

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

tjweldon/pages
==============

A lightweight standalone pagination component

01PHPCI failing

Since Jul 20Pushed 5y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

Summary
=======

[](#summary)

Pages is a lightweight pagination component. It is a paged wrapper for any collection of values.

Installation
============

[](#installation)

Composer
--------

[](#composer)

`composer require tjweldon/pages`

Usage
=====

[](#usage)

### Creating your Pages

[](#creating-your-pages)

To create your paginated collection:

```
$pages = Pages::empty()
	->appendCollection($iterableCollectionOfItems)
	->appendItem($aSingleItem)
;

```

The `$pages` variable now holds your collection of items but is not going to page them by default. To set paging:

```
$pages->limitPageSize($pageSize);

```

OR

```
$pages->limitPageCount($pageCount);

```

**Warning**: using one after the other, in either order, will ignore the first, since one value sets the other, depending on the number of items.

### Reading from your Pages

[](#reading-from-your-pages)

The Pages class is an collection of `Page` objects. `Pages` implements the `\Iterator` interface and can be looped over like an array i.e.

```
$pages = Pages::empty()->appendCollection($iterableCollectionOfItems);

foreach ($pages as $pageNumber => $page) {
	// do something
}

```

An indiviadual page can be accessed:

```
$page = $pages->getPage($pageNumber)

```

In both of these cases the `$page` variable is storing a `Page` instance. To access the items on a page:

```
$items = $page->getItems();

```

The `Page` class also implements the `\Iterator` interface so it can also be looped over

```
foreach ($page as $index => $item) {
	// do something
}

```

### Item Indexing

[](#item-indexing)

Items are indexed numeriacally, there are two schemes available. By default, pages and items in a `Page` are indexed starting at `0`, the page number is accessed via `$page->getPageNumber()` . At any time you can set the items in a page to index relative to the full item collection like so:

```
$fifthPage = Pages::empty()
	->appendCollection($oneHundredItems)
	->limitPageSize(10)
	->getPage(4)
;

$fifthPage->getPageNumber() // Returns int(4)

$items = $fifthPage
	->indexRelativeToPagination(true)
	->getItems() // returns the items on the page with sequential indexes from 40 to 49
;

```

or

```
foreach ($items->indexRelativeToPagination(true) as $index => $item) {
	echo $index . ", "; // will echo the numbers 40 to 49
}

```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

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/a9f6e7f9fc026b71d0a872ad6244c710860bd49aa6e262ba8a8d0fd4164a2c2c?d=identicon)[tjweldon](/maintainers/tjweldon)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/tjweldon-pages/health.svg)

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

###  Alternatives

[suncat/mobile-detect-bundle

Symfony2/3/4 bundle for detect mobile devices, managing mobile view types, redirect to mobile version.

4035.3M7](/packages/suncat-mobile-detect-bundle)[snowdog/frontools

Set of front-end tools for Magento 2, based on Gulp.js

4241.3M1](/packages/snowdog-frontools)[spatie/laravel-dashboard

A dashboard for Laravel

568156.1k94](/packages/spatie-laravel-dashboard)[brick/schema

Schema.org library for PHP

5163.7k1](/packages/brick-schema)[ibericode/vat-bundle

Bundle for using ibericode/vat in a Symfony environment

21254.5k](/packages/ibericode-vat-bundle)[sylius/taxonomy

Taxonomies - categorization of domain models in PHP projects.

14435.6k10](/packages/sylius-taxonomy)

PHPackages © 2026

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