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)710MITPHPPHP ^8.2CI passing

Since Jun 19Pushed 4mo 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 3d ago

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

38

—

LowBetter than 85% of packages

Maintenance64

Regular maintenance activity

Popularity10

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

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

Total

5

Last Release

396d 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 (26 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

[paysera/lib-pagination

Paginates Doctrine QueryBuilder using cursor based or offset based pagination

13191.8k1](/packages/paysera-lib-pagination)[lampager/lampager-laravel

Rapid pagination for Laravel

7641.4k](/packages/lampager-lampager-laravel)[data-dog/pager-bundle

Paginator bundle for symfony2 and doctrine orm, allows customization with filters and sorters

11103.5k7](/packages/data-dog-pager-bundle)[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.

1022.4k](/packages/rcsofttech-audit-trail-bundle)[ahmed-bhs/doctrine-doctor

Runtime analysis tool for Doctrine ORM integrated into Symfony Web Profiler. Unlike static linters, it analyzes actual query execution at runtime to detect performance bottlenecks, security vulnerabilities, and best practice violations during development with real execution context and data.

813.1k](/packages/ahmed-bhs-doctrine-doctor)

PHPackages © 2026

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