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

ActiveLibrary

benjam1/doctrine-specification
==============================

8101PHP

Since Mar 6Pushed 12y ago1 watchersCompare

[ Source](https://github.com/benja-M-1/doctrine-specification)[ Packagist](https://packagist.org/packages/benjam1/doctrine-specification)[ RSS](/packages/benjam1-doctrine-specification/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

doctrine-specification
======================

[](#doctrine-specification)

Implementation of the Specification pattern with Doctrine2.

This library is greatly inspired by Benjamin Eberlei's [blog post](http://www.whitewashing.de/2013/03/04/doctrine_repositories.html).

The first I read about the specification pattern I was sceptic: "Oh man! It's too complicated, there might be a simpler solution..." And I'm not the only one according to the comments! Then I tried this solution and I had to admit that it brings flexibility into your repository. Now you can use this library as a starting point for your project to use the specification pattern.

Usage
=====

[](#usage)

```
$spec = new AndX(
    new MySpecA(),
    new MySpecB()
);

$matcher = new Matcher();

$query = $matcher->match($em->getRepository('Foo\Bar'), 'r', $spec);

$results = $query->getResults();
```

TODO
====

[](#todo)

\[ \] Specification generator \[ \] Dynamic specification creation

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

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

---

Top Contributors

[![benja-M-1](https://avatars.githubusercontent.com/u/212269?v=4)](https://github.com/benja-M-1 "benja-M-1 (5 commits)")

### Embed Badge

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

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

PHPackages © 2026

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