PHPackages                             lampager/lampager-doctrine2 - 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. [Database &amp; ORM](/categories/database)
4. /
5. lampager/lampager-doctrine2

ActiveLibrary[Database &amp; ORM](/categories/database)

lampager/lampager-doctrine2
===========================

Rapid pagination for Doctrine 2

v0.3.0(1y ago)710[1 PRs](https://github.com/lampager/lampager-doctrine2/pulls)MITPHPPHP ^8.2CI passing

Since Jun 19Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/lampager/lampager-doctrine2)[ Packagist](https://packagist.org/packages/lampager/lampager-doctrine2)[ RSS](/packages/lampager-lampager-doctrine2/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (5)Versions (6)Used By (0)

[![lampager-doctrine2](https://user-images.githubusercontent.com/1351893/31839014-3e74b952-b61a-11e7-8d75-adba77a935ae.png)](https://user-images.githubusercontent.com/1351893/31839014-3e74b952-b61a-11e7-8d75-adba77a935ae.png)

[![Build Status](https://github.com/lampager/lampager-doctrine2/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/lampager/lampager-doctrine2/actions)[![Coverage Status](https://camo.githubusercontent.com/3868890ed4d7eb4cbd4dc5285049b7e9b1a424ddc65a8d425d35ed0c777fc092/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6c616d70616765722f6c616d70616765722d646f637472696e65322f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/lampager/lampager-doctrine2?branch=master)

Lampager for Doctrine 2
=======================

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

Rapid pagination for Doctrine 2

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

[](#requirements)

- PHP: `^8.2`
- [doctrine/orm](https://github.com/doctrine/orm): `^2.20`
- [lampager/lampager](https://github.com/lampager/lampager): `^0.5`

Note

Older versions have outdated dependency requirements. If you cannot prepare the latest environment, please refer to past releases.

Installing
----------

[](#installing)

```
composer require lampager/lampager-doctrine2
```

Usage
-----

[](#usage)

### Basic

[](#basic)

Instantiate your QueryBuilder to create the Paginator.

```
$cursor = [
    'p.id' => 3,
    'p.createdAt' => '2017-01-10 00:00:00',
    'p.updatedAt' => '2017-01-20 00:00:00',
];

$result = Paginator::create(
    $entityManager
        ->getRepository(Post::class)
        ->createQueryBuilder('p')
        ->where('p.userId = :userId')
        ->setParameter('userId', 1)
)
    ->forward()
    ->setMaxResults(5) // Or ->limit(5)
    ->orderByDesc('p.updatedAt') // ORDER BY p.updatedAt DESC, p.createdAt DESC, p.id DESC
    ->orderByDesc('p.createdAt')
    ->orderByDesc('p.id')
    ->paginate($cursor);
```

It will run the optimized DQL.

```
SELECT * FROM App\Entities\Post p
WHERE p.userId = 1
AND (
    p.updatedAt = '2017-01-20 00:00:00' AND p.createdAt = '2017-01-10 00:00:00' AND p.id  $fetchedFieldName`.

### Paginator::aggregated()

[](#paginatoraggregated)

```
Paginator::aggregated(bool $aggregated = true): $this
```

Declare that `HAVING` should be used instead of `WHERE` for aggregation.

### Paginator::setMaxResults()

[](#paginatorsetmaxresults)

Alias for `\Lampager\Paginator::limit()`.

```
Paginator::setMaxResults(int $limit): $this
```

### Paginator::transform()

[](#paginatortransform)

Transform Lampager Query into Doctrine Query.

```
Paginator::transform(\Lampager\Query $query): \Doctrine\ORM\Query
```

### Paginator::build()

[](#paginatorbuild)

Perform configure + transform.

```
Paginator::build(\Lampager\Contracts\Cursor|array $cursor = []): \Doctrine\ORM\Query
```

### Paginator::paginate()

[](#paginatorpaginate)

Perform configure + transform + process.

```
Paginator::paginate(\Lampager\Contracts\Cursor|array $cursor = []): \Lampager\PaginationResult
```

#### Arguments

[](#arguments-1)

- **`(mixed)`** ***$cursor***
     An associative array that contains `$column => $value` or an object that implements `\Lampager\Contracts\Cursor`. It must be **all-or-nothing**.
    - For initial page, omit this parameter or pass empty array.
    - For subsequent pages, pass all parameters. Partial parameters are not allowd.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance70

Regular maintenance activity

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.1% 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 ~348 days

Total

5

Last Release

494d ago

PHP version history (2 changes)v0.1.0PHP ^5.6 || ^7.0 || ^8.0

v0.3.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![mpyw](https://avatars.githubusercontent.com/u/1351893?v=4)](https://github.com/mpyw "mpyw (27 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

doctrinefastpaginationpaginatorphpsymfonypaginatordoctrinepaginationlimitoffset

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

12017.1k](/packages/rcsofttech-audit-trail-bundle)[paysera/lib-pagination

Paginates Doctrine QueryBuilder using cursor based or offset based pagination

14209.3k1](/packages/paysera-lib-pagination)

PHPackages © 2026

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