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

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

kadudutra/doctrine-pagination
=============================

Doctrine pagination

v2.1.3(5y ago)0221MITPHPPHP ^7.4

Since Mar 18Pushed 5y agoCompare

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

READMEChangelog (7)Dependencies (2)Versions (21)Used By (0)

[![Minimum PHP Version](https://camo.githubusercontent.com/0ec3ba35d7222328fe84ea90bd50e6569a1bb65a95cec0c15d9aa799f94f8f41/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545372e342d626c7565)](https://php.net/)[![Latest Stable Version](https://camo.githubusercontent.com/53c3d55708ec8bde5b06344692cd860f4f94bee49499d4dcfed6242d2cf3c8e0/68747470733a2f2f706f7365722e707567782e6f72672f6b61647564757472612f646f637472696e652d706167696e6174696f6e2f762f737461626c652e737667)](https://packagist.org/packages/kadudutra/doctrine-pagination)[![Latest Unstable Version](https://camo.githubusercontent.com/c73d36a4d7cebb5ee744c0290ace30bb4d03a970600955c3de8b490de85f8bd6/68747470733a2f2f706f7365722e707567782e6f72672f6b61647564757472612f646f637472696e652d706167696e6174696f6e2f762f756e737461626c652e737667)](https://packagist.org/packages/kadudutra/doctrine-pagination)[![License](https://camo.githubusercontent.com/d62261bdd481350c8f0b517cc44e2ecffad1c7c61872d39c242033369752a9c3/68747470733a2f2f706f7365722e707567782e6f72672f6b61647564757472612f646f637472696e652d706167696e6174696f6e2f6c6963656e73652e737667)](https://packagist.org/packages/kadudutra/doctrine-pagination)[![Total Downloads](https://camo.githubusercontent.com/05c3fc100d775ef5236c0691369f5a2886bd99256871fc59176acb24bf2e1624/68747470733a2f2f706f7365722e707567782e6f72672f6b61647564757472612f646f637472696e652d706167696e6174696f6e2f646f776e6c6f616473)](https://packagist.org/packages/kadudutra/doctrine-pagination)

This library provides a paginated repository and collection for Doctrine.

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

[](#installation)

Applications that use Symfony Flex
----------------------------------

[](#applications-that-use-symfony-flex)

Open a command console, enter your project directory and execute:

```
$ composer require kadudutra/doctrine-pagination
```

Configure Repository
====================

[](#configure-repository)

Use it as Entity repository
---------------------------

[](#use-it-as-entity-repository)

Configure PaginatedRepository in your entity:

```
namespace Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Class Task
 *
 * @ORM\Table(name="task")
 * @ORM\Entity(repositoryClass="DoctrinePagination\ORM\PaginatedRepository")
 */
class Task
{

}
```

Create your custom Paginated repository
---------------------------------------

[](#create-your-custom-paginated-repository)

Create custom repository extending PaginatedRepository:

```
namespace Repository;

use DoctrinePagination\ORM\PaginatedQueryBuilder;
use DoctrinePagination\ORM\PaginatedRepository;

/**
 * Class TaskRepository
 */
class TaskRepository extends PaginatedRepository
{

}
```

Configure your Entity:

```
namespace Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Class Task
 *
 * @ORM\Table(name="task")
 * @ORM\Entity(repositoryClass="Repository\TaskRepository")
 */
class Task
{

}
```

If needed, override processCriteria method in your custom repository to add some custom actions:

```
protected function processCriteria(PaginatedQueryBuilder $qb, array $criteria)
{
    foreach ($criteria as $field => $value) {
        switch ($field) {
            case 'description':
                $qb->andWhere(...);
                unset($criteria[$field]);
                break;
        }
    }

    parent::processCriteria($qb, $criteria);
}
```

Using Paginated Repository
==========================

[](#using-paginated-repository)

*public* **findPageBy** *($page, $per\_page, array $criteria = \[\], array $orderBy = null)*

Returns a paginated collection of elements that matches criteria.

*public* **countBy** *(array $criteria = \[\])*

Returns the total number of elements that matches criteria.

*protected* **createPaginatedQueryBuilder** *(array $criteria = \[\], $indexBy = null)*

This method is used by findPageBy and countBy methods to create a QueryBuilder, and can be used in other repository custom methods.

**processCriteria (protected)**

This method is called from createPaginatedQueryBuilder to add criteria conditions.

This can be overridden to customize those criteria conditions.

**findBy and findAll**

PaginatedRepository overrides findBy and findAll default Doctrine Repository methods to provides code compatibility.

Using Paginated Collections
===========================

[](#using-paginated-collections)

The PaginatedRepository always returns a PaginatedArrayCollection:

```
// some parameters
$page = 5;
$per_page = 10;

// get repository
$repository = $doctrine->getRepository('Task');

/** @var PaginatedArrayCollection */
$result = $repository->findPageBy($page, $per_page, ['field'=>'value']);
```

**count()**

```
// count obtained results as usual
$pageResults = $result->count(); // 10
```

**getTotal()**

```
// get total results
$totalResults = $result->getTotal(); // 95
```

**getPage()**

```
// current page
$currentPage = $result->getPage(); // 5
```

**getResultsPerPage()**

```
// current results per page
$currentResultsPerPage = $result->getResultsPerPage(); // 10
```

**getPages()**

```
// get total pages
$totalPages = $result->getPages(); // 10
```

**getNextPage()**

```
// get next page number
$nextPage = $result->getNextPage(); // 6
```

**getPrevPage()**

```
// get prev page number
$prevPage = $result->getPrevPage(); // 4
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 52.5% 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 ~92 days

Recently: every ~2 days

Total

20

Last Release

1955d ago

Major Versions

v1.0.11 → v2.02020-12-24

PHP version history (2 changes)v1.0.10PHP ^7.1

v2.0PHP ^7.4

### Community

Maintainers

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

---

Top Contributors

[![javihgil](https://avatars.githubusercontent.com/u/2581053?v=4)](https://github.com/javihgil "javihgil (21 commits)")[![kadudutra](https://avatars.githubusercontent.com/u/39005063?v=4)](https://github.com/kadudutra "kadudutra (18 commits)")[![tr33m4n](https://avatars.githubusercontent.com/u/1771667?v=4)](https://github.com/tr33m4n "tr33m4n (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58523.9M36](/packages/scienta-doctrine-json-functions)[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[pixelfederation/doctrine-resettable-em-bundle

Symfony bundle for decorating default entity managers using a resettable decorator.

20113.5k](/packages/pixelfederation-doctrine-resettable-em-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)
