PHPackages                             lampager/lampager-cakephp2 - 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. lampager/lampager-cakephp2

AbandonedArchivedCakephp-plugin[Utility &amp; Helpers](/categories/utility)

lampager/lampager-cakephp2
==========================

Rapid pagination for CakePHP 2

v1.0.0(6y ago)223MITPHPPHP ^5.6 || ^7.0

Since Nov 4Pushed 6y ago6 watchersCompare

[ Source](https://github.com/lampager/lampager-cakephp2)[ Packagist](https://packagist.org/packages/lampager/lampager-cakephp2)[ RSS](/packages/lampager-lampager-cakephp2/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (4)Dependencies (5)Versions (8)Used By (0)

[![lampager-cakephp2](https://user-images.githubusercontent.com/1351893/32145370-967f8572-bd0a-11e7-8324-10854958fd7f.png)](https://user-images.githubusercontent.com/1351893/32145370-967f8572-bd0a-11e7-8324-10854958fd7f.png)

[![Build Status](https://camo.githubusercontent.com/4972f28c23f576844610ad4cb8705a5a29e1eef370517dbe7bed8558e90a898d/68747470733a2f2f7472617669732d63692e636f6d2f6c616d70616765722f6c616d70616765722d63616b65706870322e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/lampager/lampager-cakephp2)[![Coverage Status](https://camo.githubusercontent.com/cc77a0291d97d223397ab0a76f22d83b21fbd797318785a8076a656338e1b8d1/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6c616d70616765722f6c616d70616765722d63616b65706870322f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/lampager/lampager-cakephp2?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9ed833673e052e9289ea76ae60db6b144451ee04ba2031bc01c7217e2118e9a3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6c616d70616765722f6c616d70616765722d63616b65706870322f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/lampager/lampager-cakephp2/?branch=master)

Lampager for CakePHP 2
======================

[](#lampager-for-cakephp-2)

Rapid pagination without using OFFSET

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

[](#requirements)

- PHP: ^5.6 || ^7.0
- CakePHP: ^2.10
- [lampager/lampager](https://github.com/lampager/lampager): ^0.4

### Note

[](#note)

- For CakePHP 2.x, use lampager/lampager-cakephp2 (this version).
- For CakePHP 3.x, use [lampager/lampager-cakephp v1.x](https://github.com/lampager/lampager-cakephp/tree/v1.x).
- For CakePHP 4.x, use [lampager/lampager-cakephp v2.x](https://github.com/lampager/lampager-cakephp).

Installing
----------

[](#installing)

```
composer require lampager/lampager-cakephp2
```

Move `Plugin/Lampager` to the appropriate directory if necessary.

Basic Usage
-----------

[](#basic-usage)

Load as a plugin. See [How To Install Plugins](https://book.cakephp.org/2/en/plugins/how-to-install-plugins.html) for detail.

Plugin needs to be loaded manually in `app/Config/bootstrap.php`:

```
// Be sure to require vendor/autoload.php beforehand.
// CakePlugin::load() will fail unless autoloader is properly configured.
CakePlugin::load('Lampager');
```

Next, add `'Lampager.Lampager'` to your Model class (`AppModel` is preferable):

```
class AppModel extends Model
{
    public $actsAs = [
        'Lampager.Lampager',
    ];
}
```

Use in one or more of the following methods:

- Use in Controller (via `LampagerBehavior`)
- Use in Model (via `LampagerBehavior`)

### Use in Controller

[](#use-in-controller)

At first, your `Model` class must have `'Lampager.Lampager'` enabled. Use in a way described in the Cookbook: [Pagination](https://book.cakephp.org/2/en/core-libraries/components/pagination.html). Note the options that are specific to Lampager such as `forward`, `seekable`, or `cursor`.

```
/** @var \Lampager\PaginationResult $posts */
$posts = $this->paginate(Post::class, [
    // Lampager options
    'forward' => true,
    'seekable' => true,
    'cursor' => [
        'Post' => [
            'id' => '4',
            'created' => '2017-01-01 10:00:00',
        ],
    ],

    // PaginatorComponent::settings query
    'conditions' => [
        'Post.type' => 'public',
    ],
    'order' => [
        'Post.created' => 'DESC',
        'Post.id' => 'DESC',
    ],
    'limit' => 10,
]);

$this->set('posts', $posts);
```

### Use in Model

[](#use-in-model)

At first, your `Model` class must have `'Lampager.Lampager'` enabled. Simply use `Model::find` with `lampager`. The custom find type `lampager` (see [Retrieving Your Data](https://book.cakephp.org/2/en/models/retrieving-your-data.html#creating-custom-find-types)) works in a way similar to the core find type `all`with additional parameters and post processor enabled.

```
/** @var \Lampager\PaginationResult $posts */
$posts = $this->find('lampager', [
    // Lampager options
    'forward' => true,
    'seekable' => true,
    'cursor' => [
        'Post' => [
            'id' => '4',
            'created' => '2017-01-01 10:00:00',
        ],
    ],

    // Model::find query
    'limit' => 10,
    'order' => [
        'Post.modified' => 'DESC',
        'Post.created' => 'DESC',
        'Post.id' => 'DESC',
    ],
]);

foreach ($posts as $post) {
    /** @var mixed[][] $post */
    debug($post['Post']['id']);
    debug($post['Post']['created']);
    debug($post['Post']['modified']);
}
```

Classes
-------

[](#classes)

See also: [lampager/lampager](https://github.com/lampager/lampager).

NameTypeExtendsDescription`LampagerBehavior`ClassModelBehaviorCakePHP behavior which handles `Model::find()` and `PaginatorComponent::paginate()``LampagerArrayCursor`ClassLampager\\Contracts\\`Cursor`Multi-dimensional array cursor`LampagerPaginator`ClassLampager\\`Paginator`Paginator implementation for CakePHP`LampagerArrayProcessor`ClassLampager\\`ArrayProcessor`Processor implementation for CakePHP`LampagerColumnAccess`ClassMulti-dimensional array accessor`LampagerTransformer`ClassCakePHP query genenratorAPI
---

[](#api)

See also: [lampager/lampager](https://github.com/lampager/lampager).

Using `Model::find()` or `PaginatorComponent::paginate()` is recommended. The query is merged with CakePHP query and passed to `Lampager\Query`.

### LampagerPaginator::\_\_construct()
LampagerPaginator::create()

[](#lampagerpaginator__constructlampagerpaginatorcreate)

Create a new paginator instance. These methods are not intended to be directly used in your code.

```
static LampagerPaginator::create(Model $builder, array $options): static
LampagerPaginator::__construct(Model $builder, array $options)
```

### LampagerPaginator::transform()

[](#lampagerpaginatortransform)

Transform a Lampager query into a CakePHP query.

```
LampagerPaginator::transform(\Lampager\Query $query): array
```

### LampagerPaginator::build()

[](#lampagerpaginatorbuild)

Perform configure + transform.

```
LampagerPaginator::build(array $cursor = []): array
```

### LampagerPaginator::paginate()

[](#lampagerpaginatorpaginate)

Perform configure + transform + process.

```
LampagerPaginator::paginate(array $cursor = []): \Lampager\PaginationResult
```

#### Arguments

[](#arguments)

- **`(array)`** ***$cursor***
     An associative array that contains `$column => $value`. It must be **all-or-nothing**.
    - For the initial page, omit this parameter or pass an empty array.
    - For the subsequent pages, pass all the parameters. The partial one is not allowed.

#### Return Value

[](#return-value)

e.g.,

(Default format when using `Model::find()`)

```
object(Lampager\PaginationResult)#1 (5) {
  ["records"]=>
  array(3) {
    [0]=>
    array(1) {
      ["Post"]=>
      array(3) { ... }
    }
    [1]=>
    array(1) {
      ["Post"]=>
      array(3) { ... }
    }
    [2]=>
    array(1) {
      ["Post"]=>
      array(3) { ... }
    }
  }
  ["hasPrevious"]=>
  bool(false)
  ["previousCursor"]=>
  NULL
  ["hasNext"]=>
  bool(true)
  ["nextCursor"]=>
  array(1) {
    ["Post"]=>
    array(2) {
      ["id"]=>
      string(1) "3"
      ["created"]=>
      string(19) "2017-01-01 10:00:00"
    }
  }
}
```

### LampagerTransformer::\_\_construct()

[](#lampagertransformer__construct)

Create a new transformer instance. This class is not intended to be directly used in your code.

```
LampagerTransformer::__construct(Model $builder, array $options)
```

Examples
--------

[](#examples)

This section describes the practial usages of lampager-cakephp2.

### Use in Controller

[](#use-in-controller-1)

The example below shows how to accept a cursor parameter from a request and pass it through `PaginatorComponent::settings`. Be sure that your `Model` class has `'Lampager.Lampager'` enabled.

```
class PostsController extends AppController
{
    public function index()
    {
        // Get cursor parameters
        $previous = $this->request->param('named.previous_cursor');
        $next = $this->request->param('named.next_cursor');

        $this->Paginator->settings = [
            // Lampager options
            // If the previous_cursor is not set, paginate forward; otherwise backward
            'forward' => !$previous,
            'cursor' => $previous ?: $next ?: [],
            'seekable' => true,

            // PaginatorComponent::settings query
            'conditions' => [
                'Post.type' => 'public',
            ],
            'order' => [
                'Post.created' => 'DESC',
                'Post.id' => 'DESC',
            ],
            'limit' => 10,
        ];

        /** @var \Lampager\PaginationResult $posts */
        $posts = $this->Paginator->paginate(Post::class);
        $this->set('posts', $posts);
    }
}
```

And the pagination links can be output as follows:

```
// If there is a previous page, print pagination link
if ($posts->hasPrevious) {
    echo $this->Html->link('>', [
        'controller' => 'posts',
        'action' => 'index',
        'next_cursor' => $posts->nextCursor,
    ]);
}
```

Supported database engines
--------------------------

[](#supported-database-engines)

### MySQL, MariaDB, PostgreSQL, and SQLite

[](#mysql-mariadb-postgresql-and-sqlite)

Supported!

### Microsoft SQL Server

[](#microsoft-sql-server)

Not supported.

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 97.9% 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 ~132 days

Recently: every ~160 days

Total

7

Last Release

2368d ago

Major Versions

v0.1.5 → v1.0.02020-01-05

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1351893?v=4)[mpyw](/maintainers/mpyw)[@mpyw](https://github.com/mpyw)

![](https://avatars.githubusercontent.com/u/6535425?v=4)[Chitoku](/maintainers/chitoku-k)[@chitoku-k](https://github.com/chitoku-k)

---

Top Contributors

[![chitoku-k](https://avatars.githubusercontent.com/u/6535425?v=4)](https://github.com/chitoku-k "chitoku-k (46 commits)")[![mpyw](https://avatars.githubusercontent.com/u/1351893?v=4)](https://github.com/mpyw "mpyw (1 commits)")

---

Tags

cakephp2fastpaginationpaginatorphppaginatorpaginationcakephplimitoffset

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lampager-lampager-cakephp2/health.svg)

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

###  Alternatives

[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[lampager/lampager-laravel

Rapid pagination for Laravel

7642.4k](/packages/lampager-lampager-laravel)[lampager/lampager

Rapid pagination without using OFFSET

3779.4k5](/packages/lampager-lampager)[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.

3741.3M21](/packages/jasongrimes-paginator)[beberlei/porpaginas

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

163632.5k13](/packages/beberlei-porpaginas)[coffeecode/paginator

Paginator is simple and is ready to generate results navigation in your application

12659.7k1](/packages/coffeecode-paginator)

PHPackages © 2026

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