PHPackages                             lcavero/doctrine-paginator-bundle - 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. lcavero/doctrine-paginator-bundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

lcavero/doctrine-paginator-bundle
=================================

Paginate DQL sentences

1.1.x-dev(6y ago)5528MITPHPPHP &gt;=5.5.9

Since Oct 26Pushed 6y agoCompare

[ Source](https://github.com/lcavero/DoctrinePaginatorBundle)[ Packagist](https://packagist.org/packages/lcavero/doctrine-paginator-bundle)[ RSS](/packages/lcavero-doctrine-paginator-bundle/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (7)Versions (3)Used By (0)

DoctrinePaginatorBundle
=======================

[](#doctrinepaginatorbundle)

The **DoctrinePaginatorBundle** bundle allows you to page your DQL statements.
It is ideal for returning paged datasets, including searching and filtering data.

Table of Contents
-----------------

[](#table-of-contents)

1. [Installation](#installation)
2. [Basic Usage](#basic-usage)
3. [Pagination Results](#pagination-results)
4. [Search and Filters](#search-and-filters)
    4.1 [Behavior](#behavior)
    4.2 [Structure](#structure)
    4.3 [Associations](#associations)
    4.4 [Assocations and ORDER BY](#associations-and-order-by)
5. [Configuration](#configuration)
    5.1 [Accepted Boolean values](#accepted-boolean-values)
    5.2 [Strict mode](#strict-mode)

Installation
------------

[](#installation)

You can install it using composer

```
composer require lcavero/doctrine-paginator-bundle dev-master

```

Then add the bundle to your kernel:

```
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ...

            new LCavero\DoctrinePaginatorBundle\DoctrinePaginatorBundle(),
        ];

        // ...
    }
}
```

What does this bundle?

It converts an initial DQL sentence to a paginated sentence based on the paginator and search options.

Basic usage
-----------

[](#basic-usage)

```
use LCavero\DoctrinePaginatorBundle\Paginator\PaginatorOptions;

class MyController
{
    public function getUsersAction()
    {
        // Define the standard DQL sentence
        $dql = 'SELECT a FROM AppBundle:User WHERE a.age > 18'

        // Create the Query
        $query = $entity_manager->createQuery($dql);

        // Define paginator options (page, per_page, order, order_by, search, filters)
        $opts = new PaginatorOptions(4, 10, 'asc', 'id');

        // Paginate the data, this returns an array with the data and other interesting info
        $pagination = $container->get('lcav_doctrine_paginator')->paginate($query, $opts);

        // Now you have the users paginated and filtered, you can return them or do something amazing
        $users = $pagination['data'];

        // ..
    }
}
```

Pagination results
------------------

[](#pagination-results)

Call **paginate** returns some interesting info:

- **data:** An array with the paginated result
- **count:** Total number of items (filtered but not paged)
- **current\_page:** The current page
- **total\_pages:** Total number of pages of the filtered result
- **per\_page:** Items by page

That info it's ussually interesting to display pagination options in a frontend

Search and Filters
------------------

[](#search-and-filters)

###### BEHAVIOR

[](#behavior)

Filters and search are similar, the difference is that a search is a set of conditions that at least one of them must match, however, each filter must match.
You can think about this how a conditional structure:

```
    (STANDARD SENTENCE) AND (FILTER 1 AND FILTER 2) AND (SEARCH 1 OR SEARCH 2)

```

###### STRUCTURE

[](#structure)

Search and filters have the same structure, an array with key **=&gt;** value.
The key is the name of the entity field, the value is ... obviously the value.

So if you have the following entity:

```
class User
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @var string
     *
     * @ORM\Column(name="email", type="string", length=255, unique=true)
     */
    protected $email;

    /**
     * @var string
     *
     * @ORM\Column(name="name", type="string", length=255)
     */
    protected $name;

    /**
     * @ORM\ManyToMany(targetEntity="Group", mappedBy="users")
     */
    private $groups;

    // ..
}
```

You can make, for example:

```
    // Returns users which email contains lcavero or which name contains luis (or Luis, all search and filters are case insensitive)
    $search  = ['email' => 'lcavero', 'name' => 'Luis'];

    // Returns users which email contains roma and which name contains susana
    $filters = ['email' => 'roma', 'name' => 'Susana'];

    // Returns users which email contains maria and whitch name contains paula and can optionally contains jonh
    $search  = ['email' => 'maria', 'name' => 'Jonh'];
    $filters = ['name' => 'Paula'];

```

###### ASSOCIATIONS

[](#associations)

Ok, **thats great!** But what about entity associations? This **User** class have a **many to many** association with groups, and I want to filter by them!

Ok, no problem, suppose the following entity:

```
class Group
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @var string
     *
     * @ORM\Column(name="name", type="string", length=255)
     */
    protected $name;

    /**
     * @ORM\ManyToMany(targetEntity="User", inversedBy="groups")
     */
    private $users;
    // ..
}
```

As you can see, a group can be represented by the field **name**, so I want to filter by the groups name, and a User has a field **groups** to makes the association possible.
So ... if you want filter the users whose groups are named *GroupA*, you should do:

```
    // You can do it also with search and order_by
    $filter = ['groups.name' => 'GroupA']
```

**That's All!** You can do it with any type of association (1-1, 1-N, N-M ....).

###### ASSOCIATIONS AND ORDER BY

[](#associations-and-order-by)

You can use the above sintax to order by an association field, but don't forget that you can only order by **One-to-One** or **Many-to-One** associations.

Configuration
-------------

[](#configuration)

###### ACCEPTED BOOLEAN VALUES

[](#accepted-boolean-values)

You can define the accepted boolean values, that means, by default if you search on a boolean field with a not-boolean value, the search is ignored (the DQL sentence searchs for -1 value instead 0/1). Maybe you want define your own accepted boolean values.

###### STRICT MODE

[](#strict-mode)

You can also enable/disable the *strict mode*. By defaults, if you search *"Hello World"*, the DQL sentence searchs for the words *"Hello"*, *"World"* and *"Hello World"*, but you can dissable it enabling the *strict mode*. That means, only *"Hello World"* can matchs.

```
# app/config/config.yml

lcavero_doctrine_paginator:
    mapping:
        boolean_true_values: [1, 'true']
        boolean_false_values: [0, 'false']

    search:
        strict_mode: false
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

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

Total

2

Last Release

2529d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e4bcb6db17ac5267f808a5655dd95a78557cda894780ab8a8a5d59ddd27e94f?d=identicon)[lcavero](/maintainers/lcavero)

---

Tags

paginatordqlpagination

### Embed Badge

![Health badge](/badges/lcavero-doctrine-paginator-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/lcavero-doctrine-paginator-bundle/health.svg)](https://phpackages.com/packages/lcavero-doctrine-paginator-bundle)
```

###  Alternatives

[pagerfanta/pagerfanta

Pagination for PHP

42550.0M245](/packages/pagerfanta-pagerfanta)[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)[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)[petkopara/crud-generator-bundle

Symfony3 bundle for CRUD generation with pagination, filtering, sorting, page size, bulk delete and bootstrap3 markup. This Generator supports Doctrine association mapping.

7257.9k](/packages/petkopara-crud-generator-bundle)[paysera/lib-pagination

Paginates Doctrine QueryBuilder using cursor based or offset based pagination

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

PHPackages © 2026

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