PHPackages                             api-skeletons/doctrine-criteria - 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. api-skeletons/doctrine-criteria

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

api-skeletons/doctrine-criteria
===============================

Doctrine Criteria from Array Parameters

2.0.3(5y ago)21111BSD-3-ClausePHPPHP ^7.1CI failing

Since Jul 6Pushed 5y ago2 watchersCompare

[ Source](https://github.com/API-Skeletons/doctrine-criteria)[ Packagist](https://packagist.org/packages/api-skeletons/doctrine-criteria)[ Docs](https://api-skeletons.com)[ RSS](/packages/api-skeletons-doctrine-criteria/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (4)Dependencies (12)Versions (5)Used By (0)

Doctrine Criteria for Laminas
=============================

[](#doctrine-criteria-for-laminas)

[![Build Status](https://camo.githubusercontent.com/a6875475ae2844f588a37c9f2d6870a3025ac11fd8dec5bd83cbcad1e3dedadc/68747470733a2f2f7472617669732d63692e6f72672f4150492d536b656c65746f6e732f646f637472696e652d63726974657269612e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/API-Skeletons/doctrine-criteria)[![Coverage](https://camo.githubusercontent.com/dfdb70b12d34d115c8c7500fc71fc5d39b0c06bbbbf7efad7bb92e9ed94a9439/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f4150492d536b656c65746f6e732f646f637472696e652d63726974657269612f62616467652e7376673f6272616e63683d6d617374657226313233)](https://coveralls.io/repos/github/API-Skeletons/doctrine-criteria/badge.svg?branch=master&123)[![Gitter](https://camo.githubusercontent.com/c45f0485e89d3cd41f666d7d4bb5875cb59836555e05b6b11f77ed223eb64c0c/68747470733a2f2f6261646765732e6769747465722e696d2f6170692d736b656c65746f6e732f6f70656e2d736f757263652e737667)](https://gitter.im/api-skeletons/open-source)[![Patreon](https://camo.githubusercontent.com/f9e075baad95563481d35174d43ef50757281abb6bc795d0f473fad452afa030/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f70617472656f6e2d646f6e6174652d79656c6c6f772e737667)](https://www.patreon.com/apiskeletons)[![Total Downloads](https://camo.githubusercontent.com/820bce161ccab6d551b2ec692792ee4ff35d2af910c250b763d4a938f9a7c80c/68747470733a2f2f706f7365722e707567782e6f72672f6170692d736b656c65746f6e732f646f637472696e652d63726974657269612f646f776e6c6f616473)](https://packagist.org/packages/api-skeletons/doctrine-criteria)

This library builds a Criteria object from array parameters for use in filtering collections.

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

[](#installation)

Installation of this module uses composer. For composer documentation, please refer to [getcomposer.org](http://getcomposer.org/).

```
$ composer require api-skeletons/doctrine-criteria
```

Once installed, add `ApiSkeletons\Doctrine\Criteria` to your list of modules inside `config/application.config.php` or `config/modules.config.php`.

> ### laminas-component-installer
>
> [](#laminas-component-installer)
>
> If you use [laminas-component-installer](https://github.com/laminas/laminas-component-installer), that plugin will install doctrine-criteria as a module for you.

Configuring the Module
----------------------

[](#configuring-the-module)

Copy `config/apiskeletons-doctrine-criteria.global.php.dist` to `config/autoload/apiskeletons-doctrine-criteria.global.php`and edit the list of aliases for those you want enabled. By default all supported expressions are enabled.

> Note AND and OR composite expressions are not supported yet.

Use
---

[](#use)

```
use Doctrine\Common\Util\ClassUtils;
use ApiSkeletons\Doctrine\Criteria\Builder as CriteriaBuilder;

$filterArray = [
    [
        'type' => 'eq',
        'field' => 'name',
        'value' => 'Grateful Dead',
    ],
    [
        'type' => 'beginswith',
        'field' => 'state',
        'value' => 'UT',
    ],
];

$orderByArray = [
    [
        'type' => 'field',
        'field' => 'venue',
        'direction' => 'asc',
    ]
];

$criteriaBuilder = $container->get(CriteriaBuilder::class);
$entityClassName = ClassUtils::getRealClass(get_class($collection->first()));
$metadata = $objectManager->getClassMetadata($entityClassName);
$criteria = $criteriaBuilder->create($metadata, $filterArray, $orderByArray);

$filteredCollection = $collection->matching($criteria);
```

Filters
-------

[](#filters)

Filters are not simple key/value pairs. Filters are a key-less array of filter definitions. Each filter definition is an array and the array values vary for each filter type.

Each filter definition requires at a minimum a 'type'. A type references the configuration key such as 'eq', 'neq', 'contains'.

Each filter definition requires at a minimum a 'field'. This is the name of a field on the target entity.

Each filter definition may specify 'where' with values of either 'and', 'or'.

Format of Date Fields
---------------------

[](#format-of-date-fields)

When a date field is involved in a filter you may specify the format of the date using PHP date formatting options. The default date format is ISO 8601 `Y-m-d\TH:i:sP` If you have a date field which is just `Y-m-d` then add the format to the filter. For complete date format options see [DateTime::createFromFormat](http://php.net/manual/en/datetime.createfromformat.php)

```
[
    'format' => 'Y-m-d',
    'value' => '2014-02-04',
]
```

Included Filter Types
---------------------

[](#included-filter-types)

Equals:

> Doctrine Collections does not currently support DateTime `Equals` comparisons. Any DateTime values sent through the `equals` filter will always return not equals. This is a shortcoming of [doctrine/collections](https://github.com/doctrine/collections)and not this module. Other comparison operators should work as expected.

```
['type' => 'eq', 'field' => 'fieldName', 'value' => 'matchValue']
```

Not Equals:

```
['type' => 'neq', 'field' => 'fieldName', 'value' => 'matchValue']
```

Less Than:

```
['type' => 'lt', 'field' => 'fieldName', 'value' => 'matchValue']
```

Less Than or Equals:

```
['type' => 'lte', 'field' => 'fieldName', 'value' => 'matchValue']
```

Greater Than:

```
['type' => 'gt', 'field' => 'fieldName', 'value' => 'matchValue']
```

Greater Than or Equals:

```
['type' => 'gte', 'field' => 'fieldName', 'value' => 'matchValue']
```

Contains:

> Used to search inside of a string. Comlimentary with Starts With &amp; Ends With, contains matches a string inside any part of the value.

```
['type' => 'contains', 'field' => 'fieldName', 'value' => 'matchValue']
```

Starts With:

```
['type' => 'startswith', 'field' => 'fieldName', 'value' => 'matchValue']
```

Ends With:

```
['type' => 'endswith', 'field' => 'fieldName', 'value' => 'matchValue']
```

Member Of:

> Used to search inside an array field to match the matchValue to an array element.

```
['type' => 'memeberof', 'field' => 'fieldName', 'value' => 'matchValue']
```

In:

> Note: Dates in the In and NotIn filters are not handled as dates. It is recommended you use other filters instead of these filters for date datatypes.

```
['type' => 'in', 'field' => 'fieldName', 'values' => [1, 2, 3]]
```

NotIn:

> Note: Dates in the In and NotIn filters are not handled as dates. It is recommended you use other filters instead of these filters for date datatypes.

```
['type' => 'notin', 'field' => 'fieldName', 'values' => [1, 2, 3]]
```

IsNull:

> Used to determine if the field is null. There is no corresponding IsNotNull.

```
['type' => 'isnull', 'field' => 'fieldName']
```

OrderBy
-------

[](#orderby)

Field:

```
['type' => 'field', 'field' => 'fieldName', 'direction' => 'desc']
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

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.

###  Release Activity

Cadence

Every ~30 days

Total

4

Last Release

2045d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/49dd7d9dba889ac674b0da447d9c1e69d1128dc3ccbaef98ba83d6ee519fc2d6?d=identicon)[tom\_anderson](/maintainers/tom_anderson)

---

Top Contributors

[![TomHAnderson](https://avatars.githubusercontent.com/u/493920?v=4)](https://github.com/TomHAnderson "TomHAnderson (37 commits)")

---

Tags

laminasormdoctrinefiltercriteria

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/api-skeletons-doctrine-criteria/health.svg)

```
[![Health](https://phpackages.com/badges/api-skeletons-doctrine-criteria/health.svg)](https://phpackages.com/packages/api-skeletons-doctrine-criteria)
```

###  Alternatives

[doctrine/doctrine-orm-module

Laminas Module that provides Doctrine ORM functionality

4407.3M293](/packages/doctrine-doctrine-orm-module)[doctrine/doctrine-mongo-odm-module

Laminas Module which provides Doctrine MongoDB ODM functionality

86676.6k35](/packages/doctrine-doctrine-mongo-odm-module)[mediagone/doctrine-specifications

Doctrine implementation of repository Specifications pattern

353.8k3](/packages/mediagone-doctrine-specifications)

PHPackages © 2026

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