PHPackages                             lucasgiori/pagination-doctrine - 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. lucasgiori/pagination-doctrine

ActiveLibrary

lucasgiori/pagination-doctrine
==============================

Doctrine pagination

v1.0.3(5y ago)117MITPHPPHP ^8.0

Since Mar 12Pushed 5y ago1 watchersCompare

[ Source](https://github.com/LucasGiori/pagination-doctrine)[ Packagist](https://packagist.org/packages/lucasgiori/pagination-doctrine)[ RSS](/packages/lucasgiori-pagination-doctrine/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

[![Minimum PHP Version](https://camo.githubusercontent.com/911a83e2aa6fe73660ab613629a95c76622bf03049a7344e80c5ea72d4ef9c7d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e302d626c7565)](https://php.net/)[![License](https://camo.githubusercontent.com/bf90001826855839d8e3423d4ea57f66a21d2834bbc56dae2cdca90a3680dd51/68747470733a2f2f706f7365722e707567782e6f72672f6c7563617367696f72692f706167696e6174696f6e2d646f637472696e652f6c6963656e73652e737667)](https://packagist.org/packages/lucasgiori/pagination-doctrine)

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 lucasgiori/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);
}
```

Parameter DTO to facilitate data searches:

```
use Doctrine\ORM\Query;
use DoctrinePagination\DTO\Params;

$params = (new Params())
                ->setCriteria(["field" => "teste"]) // Array the fields and values to apply filter in sql
                ->setPage(1) // Page of query data
                ->setPerPage(10) // Quantity per page
                ->setHydrateMode(Query::HYDRATE_ARRAY) //Result handling mode
                ->setSearchField("nome") // Search Field define field to apply `like` of sql
                ->setSearch("gazin"); // Field Value  apply `like` in sql

```

Class that performs the search of data consuming DTO and return PaginatedArrayCollention;

```
use DoctrinePagination\ORM\PaginatedRepository;
use DoctrinePagination\DTO\Params;

class Example extends PaginatedRepository {

    public function findWithFilter(Params $params): ?PaginatedArrayCollection
    {
        return $this->findPageWithDTO($params);
    }
}
```

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

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

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

Total

4

Last Release

1848d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/34003961?v=4)[Lucas Giori Cesconetto](/maintainers/lucasgiori)[@LucasGiori](https://github.com/LucasGiori)

---

Top Contributors

[![LucasGiori](https://avatars.githubusercontent.com/u/34003961?v=4)](https://github.com/LucasGiori "LucasGiori (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[neos/flow

Flow Application Framework

862.0M451](/packages/neos-flow)[api-platform/doctrine-orm

Doctrine ORM bridge

243.1M39](/packages/api-platform-doctrine-orm)[neos/flow-development-collection

Flow packages in a joined repository for pull requests.

144179.3k3](/packages/neos-flow-development-collection)[pixelfederation/doctrine-resettable-em-bundle

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

20113.5k](/packages/pixelfederation-doctrine-resettable-em-bundle)[leapt/core-bundle

Symfony LeaptCoreBundle

2529.1k4](/packages/leapt-core-bundle)

PHPackages © 2026

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