PHPackages                             demos-europe/edt-dql - 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. demos-europe/edt-dql

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

demos-europe/edt-dql
====================

Extension for demos-europe/edt-queries to use Doctrine ORM as data source.

0.28.0(1mo ago)225.6k↑40.8%1MITPHPPHP ^8.1

Since Jun 23Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/demos-europe/edt-dql)[ Packagist](https://packagist.org/packages/demos-europe/edt-dql)[ RSS](/packages/demos-europe-edt-dql/feed)WikiDiscussions main Synced 3d ago

READMEChangelogDependencies (10)Versions (113)Used By (1)

DoctrineQueryGenerator
======================

[](#doctrinequerygenerator)

Extends `edt/queries` with support for Doctrine ORM.

Also functions as helper library for [Doctrine ORM](https://www.doctrine-project.org/projects/orm.html) to generate [DQL](https://www.doctrine-project.org/projects/doctrine-orm/en/2.7/reference/dql-doctrine-query-language.html)queries. Currently, the focus lies in the detection of join clauses from a given property path to sort and filter the result set.

A basic understanding of the Doctrine ORM by the user is assumed for this library to be used.

Example
-------

[](#example)

Suppose we have a `Book`, `Person` and `Address` entity.

A `Book` has an `author` property which references `Person` entity.

A `Person` has a `birth` property containing information about the birth location and date.

An `Birth` entity has a `country` property which is a string.

The goal is to get all `Book` entities of which the author was born in the USA. This could be done by first fetching all entities from the database and filter the result in PHP. But for performance and memory reasons it makes sense to execute the filter in the database.

With DQL we could create a query with two joins to get the desired result:

```
use \Tests\data\DqlModel\Book;
$queryBuilder = $this->getEntityManager()->createQueryBuilder()
    ->select('Book')
    ->from(Book::class, 'Book')
    ->leftJoin('Book.author', 'Person')
    ->leftJoin('Person.birth', 'Birth')
    ->where('Birth.country = :countryName')
    ->setParameter('countryName', 'USA');
```

This library can generate a similar query builder from the following code:

```
use \Tests\data\DqlModel\Book;
use EDT\DqlQuerying\ConditionFactories\DqlConditionFactory;
use \EDT\DqlQuerying\Utilities\QueryBuilderPreparer;
/** @var \Doctrine\ORM\EntityManager $entityManager */
$entityManager = $this->getEntityManager();
$conditionFactory = new DqlConditionFactory();
$metadataFactory = $entityManager->getMetadataFactory();

$builderPreparer = new QueryBuilderPreparer(Book::class, $metadataFactory, new JoinFinder($metadataFactory));
$builderPreparer->setWhereExpressions([
    $conditionFactory->propertyHasValue('USA', 'authors', 'birth', 'country'),
]);

$builderPreparer->fillQueryBuilder($entityManager->createQueryBuilder());
```

The main advantage of the second version does not lie in line count or readability but in the removal of the need to manually specify the query in detail. This allows dynamically receiving queries and directly executing them in the database (provided authorization and validation is checked beforehand).

Conditions
----------

[](#conditions)

Beside the `PropertyHasValue` shown above more condition types are supported. All conditions provided by the library can be found and created using the `DqlConditionFactory` class.

If the provided conditions do not suffice you can [write you own clauses](writing_dql_clauses.md) by implementing `ClauseInterface`.

### Condition Nesting

[](#condition-nesting)

Conditions can be grouped together using `AND` or `OR` conjunctions:

```
$conditionFactory = new EDT\DqlQuerying\ConditionFactories\DqlConditionFactory();
$andConditions = [ /* ... */];
$orConditions = [ /* ... */];
$orCondition = $conditionFactory->anyConditionApplies(...$orConditions);
$nestedCondition = $conditionFactory->allConditionsApply(...$andConditions);
```

Sorting
-------

[](#sorting)

Defining the sorting can be done similarly as defining conditions. In the following example books will be sorted by their authors name as first priority and the authors birthdate as second priority.

```
use EDT\DqlQuerying\ConditionFactories\DqlConditionFactory;
use EDT\DqlQuerying\SortMethodFactories\SortMethodFactory;
use \Tests\data\DqlModel\Book;
use EDT\DqlQuerying\Utilities\QueryBuilderPreparer;
/** @var \Doctrine\ORM\EntityManager $entityManager */
$entityManager = $this->getEntityManager();
$conditionFactory = new DqlConditionFactory();
$sortingFactory = new SortMethodFactory();
$metadataFactory = $entityManager->getMetadataFactory();

$builderPreparer = new QueryBuilderPreparer(Book::class, $metadataFactory, new JoinFinder($metadataFactory));
$builderPreparer->setSelectExpressions([
    $sortingFactory->propertyAscending('authors', 'name'),
    $sortingFactory->propertyDescending('authors', 'birthdate'),
]);

$builderPreparer->fillQueryBuilder($entityManager->createQueryBuilder());
```

If the provided sort implementations do not suffice you can [write you own sort implementation](writing_dql_clauses.md#OrderByInterface).

Credits and acknowledgements
----------------------------

[](#credits-and-acknowledgements)

Conception and implementation by Christian Dressler with many thanks to [eFrane](https://github.com/eFrane).

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance89

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 99.7% 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

Recently: every ~182 days

Total

111

Last Release

58d ago

PHP version history (5 changes)0.6.1PHP &gt;=7.3,&lt;8.2

0.8.0PHP &gt;=7.3,&lt;8

0.13.0PHP &gt;=7.4,&lt;8

0.14.1PHP ^7.4 || ^8.0

0.17.5PHP ^8.1

### Community

Maintainers

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

---

Top Contributors

[![actions-user](https://avatars.githubusercontent.com/u/65916846?v=4)](https://github.com/actions-user "actions-user (294 commits)")[![graupnerdemos](https://avatars.githubusercontent.com/u/40465804?v=4)](https://github.com/graupnerdemos "graupnerdemos (1 commits)")

### Embed Badge

![Health badge](/badges/demos-europe-edt-dql/health.svg)

```
[![Health](https://phpackages.com/badges/demos-europe-edt-dql/health.svg)](https://phpackages.com/packages/demos-europe-edt-dql)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[oro/platform

Business Application Platform (BAP)

645143.5k115](/packages/oro-platform)[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8465.5M96](/packages/laravel-doctrine-orm)[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.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)

PHPackages © 2026

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