PHPackages                             gbprod/doctrine-specification - 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. gbprod/doctrine-specification

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

gbprod/doctrine-specification
=============================

This library allows you to write Doctrine ORM queries using the specification pattern

v2.1.0(8y ago)63.1k1MITPHPPHP ^7.0

Since Mar 5Pushed 8y ago1 watchersCompare

[ Source](https://github.com/gbprod/doctrine-specification)[ Packagist](https://packagist.org/packages/gbprod/doctrine-specification)[ RSS](/packages/gbprod-doctrine-specification/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (3)Versions (12)Used By (1)

Doctrine specification
======================

[](#doctrine-specification)

[![Build Status](https://camo.githubusercontent.com/289908ee082bf72b25bb90960a2d757de6bc598c151dfa4db2bdc6321d75e3fe/68747470733a2f2f7472617669732d63692e6f72672f676270726f642f646f637472696e652d73706563696669636174696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/gbprod/doctrine-specification)[![codecov](https://camo.githubusercontent.com/47caa96ea5c59b10d29d20da0e3a72bc799f176b4fa2a192a665dc65557eec24/68747470733a2f2f636f6465636f762e696f2f67682f676270726f642f646f637472696e652d73706563696669636174696f6e2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/gbprod/doctrine-specification)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7b6dcdd059063cf4edd92fc9fecb57242fd2b223e66b07dedc9393eafdc8e531/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f676270726f642f646f637472696e652d73706563696669636174696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/gbprod/doctrine-specification/?branch=master)[![Dependency Status](https://camo.githubusercontent.com/e228cee2eea8aa98f419600af1d69ae4f9c02364ebaf8fc4c2296fe1cee0bf4b/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3537346139626338636538643065303034313330643333302f62616467652e737667)](https://www.versioneye.com/user/projects/574a9bc8ce8d0e004130d330)

[![Latest Stable Version](https://camo.githubusercontent.com/3584537e8a729ed783cbf3f269cc6eb908d4a564f7d957e383351b0c42ea45c8/68747470733a2f2f706f7365722e707567782e6f72672f676270726f642f646f637472696e652d73706563696669636174696f6e2f762f737461626c65)](https://packagist.org/packages/gbprod/doctrine-specification)[![Total Downloads](https://camo.githubusercontent.com/f8d9864857f9441c96bab6e361f1e8347fe556130cfcff59661d0646a847c9f4/68747470733a2f2f706f7365722e707567782e6f72672f676270726f642f646f637472696e652d73706563696669636174696f6e2f646f776e6c6f616473)](https://packagist.org/packages/gbprod/doctrine-specification)[![Latest Unstable Version](https://camo.githubusercontent.com/dba0fa03162e679aee0f5b46d78b98f1d442d7f4dceb5c1836820db953a9b074/68747470733a2f2f706f7365722e707567782e6f72672f676270726f642f646f637472696e652d73706563696669636174696f6e2f762f756e737461626c65)](https://packagist.org/packages/gbprod/doctrine-specification)[![License](https://camo.githubusercontent.com/e7f7c9f4c72cc747f8b9d70aab79bdafc5bd847b3d5b81297a6f90337b5de405/68747470733a2f2f706f7365722e707567782e6f72672f676270726f642f646f637472696e652d73706563696669636174696f6e2f6c6963656e7365)](https://packagist.org/packages/gbprod/doctrine-specification)

This library allows you to write Doctrine ORM queries using the [specification pattern](http://en.wikipedia.org/wiki/Specification_pattern).

Usage
-----

[](#usage)

You can write specifications using [gbprod/specification](https://github.com/gbprod/specification) library.

### Creates a doctrine specification filter

[](#creates-a-doctrine-specification-filter)

```
namespace GBProd\Acme\Doctrine\SpecificationFactory;

use GBProd\DoctrineSpecification\QueryFactory\Factory;
use GBProd\Specification\Specification;
use Doctrine\ORM\QueryBuilder;

class IsAvailableFactory implements Factory
{
    public function create(Specification $spec, QueryFactory $qb)
    {
        return $qb->expr()
            ->andx(
                $qb->expr()->eq('available', "0"),
                $qb->expr()->gt('limitDate', "2016-03-05 00:00:00"),
            )
        ;
    }
}
```

### Configure

[](#configure)

```
$registry = new GBProd\DoctrineSpecification\Registry();

$handler = new GBProd\DoctrineSpecification\Handler(
    $registry,
    $this->em->createQueryBuilder()
);

$handler->registerFactory(
    IsAvailable::class,
    new IsAvailableFactory()
);

$handler->registerFactory(
    StockGreaterThan::class,
    new StockGreaterThanFactory()
);
```

### Use it

[](#use-it)

```
$availableWithLowStock = (new IsAvailable())
    ->andX((new StockGreaterThan(4))->not())
;

$qb = $this->em
    ->getRepository('GBProd\Acme\CoreDomain\Product\Product')
    ->createQueryBuilder('p')
;

$qb->where(
    $handler->handle($availableWithLowStock)
);

return $qb->getQuery()->getResult();
```

Requirements
------------

[](#requirements)

- PHP 7.0+

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

[](#installation)

### Using composer

[](#using-composer)

```
composer require gbprod/doctrine-specification
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

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

Recently: every ~57 days

Total

11

Last Release

3110d ago

Major Versions

v0.2.0 → v1.0.02017-06-25

v1.0.x-dev → v2.0.02017-06-27

PHP version history (2 changes)v1.0.0PHP &gt;=5.6

v2.0.0PHP ^7.0

### Community

Maintainers

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

---

Top Contributors

[![gbprod](https://avatars.githubusercontent.com/u/3751019?v=4)](https://github.com/gbprod "gbprod (34 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gbprod-doctrine-specification/health.svg)

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k18.3M418](/packages/easycorp-easyadmin-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.

12017.1k](/packages/rcsofttech-audit-trail-bundle)[kimai/kimai

Kimai - Time Tracking

4.8k9.4k1](/packages/kimai-kimai)[api-platform/doctrine-orm

Doctrine ORM bridge

314.8M106](/packages/api-platform-doctrine-orm)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1617.3k16](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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