PHPackages                             queo/doctrine-filter - 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. queo/doctrine-filter

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

queo/doctrine-filter
====================

Easy filter for Doctrine ORM

v2.1.0(9mo ago)013.3k↓30.6%[1 PRs](https://github.com/queoGmbH/doctrine-filter/pulls)MITPHPPHP &gt;=7.4CI passing

Since May 17Pushed 8mo agoCompare

[ Source](https://github.com/queoGmbH/doctrine-filter)[ Packagist](https://packagist.org/packages/queo/doctrine-filter)[ RSS](/packages/queo-doctrine-filter/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (8)Versions (18)Used By (0)

Doctrine-Filter
===============

[](#doctrine-filter)

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

[](#installation)

```
composer require queo/doctrine-filter
```

Usage
-----

[](#usage)

If you would like to use the filter, create a new class and implement the `FilterInterface`.

```
use Queo\DoctrineFilter\FilterBuilder;
use Queo\DoctrineFilter\FilterInterface;

class MyFilter implements FilterInterface
{
    public function buildFilter(FilterBuilder $builder)
    {
        // ...
    }
}
```

Now you can start defining your filter, by calling `$builder->add($name, $type)`.

```
public function buildFilter(FilterBuilder $builder)
{
    $builder
        ->add('category', EqualFilterType::class)
        ->add('price_max', LessThanEqualFilterType::class)
        ->orderBy('price', 'DESC);
}
```

The name is the key by which the filter will be used. So if you would like to query your entity on the category, you will have to make sure to provide an array that has a key of `category`.

There are several different filter types that you can use. Have a look at the list below.

To use the filter on your entity, the easiest solution is to create a custom repository and use the `EntityFilterTrait`.

```
use Doctrine\ORM\EntityRepository;
use Queo\DoctrineFilter\Traits\EntityFilterTrait;

class MyRepository extends EntityRepository
{
    use EntityFilterTrait;
}
```

To perform the query, you can now call the newly added `filter` method.

```
$result = $em->getRepository(MyEntity::class)->filter(new MyFilter(), [
	'category' => 2,
	'price_max' => 80
]);

```

This method will return all entities with a category of 2 and a price that is less than or equal to 80.

Ordering results
----------------

[](#ordering-results)

You also have the option to specify the order of the result by using the `orderBy` method. The first argument is the name of the filter, the second argument defines a possible default sorting. You can pass in `'ASC'` or `'DESC'`. Note that after setting the default values, you won't be able to pass a value to the filter. If you need the ability to define the ordering by the search params, pass in `null` as the second argument.

Filter Types
------------

[](#filter-types)

### BetweenFilterType

[](#betweenfiltertype)

This filter can be used for ranges and will expose two search keys that you can use.

```
use Queo\DoctrineFilter\Type\BetweenFilterType;

$builder
	->add('price', BetweenFilterType::class, [
		'lower_bound_suffix' => 'from',
		'upper_bound_suffix' => 'to',
	]);

//...

$em->getRepository(MyEntity::class)->filter(new MyFilter(), [
	'price_from' => 40,
	'price_to' => 80
]);
```

OptionDescriptionDefaultlower\_bound\_suffixThe suffix of the lower bound'since'upper\_bound\_suffixThe suffix of the upper bound'until'include\_lower\_boundShould the lower bound be included?trueinclude\_upper\_boundShould the upper bound be included?true### ClosureFilterType

[](#closurefiltertype)

### ComparableFilterType

[](#comparablefiltertype)

### EqualFilterType

[](#equalfiltertype)

With this filter the database value has to be the same as the search value.

### GreaterThanEqualFilterType

[](#greaterthanequalfiltertype)

The database value has to be greater than or equal to the search value.

### GreaterThanFilterType

[](#greaterthanfiltertype)

The database value has to be greater than the search value.

### InFilterType

[](#infiltertype)

The database value has to be in the given search values.

### InstanceOfFilterType

[](#instanceoffiltertype)

If you use inheritance mapping, you can use this filter to return only specific entities. The search values has to be equal to the defined key in the DiscriminatorMap.

### LessThanEqualFilterType

[](#lessthanequalfiltertype)

The database value has to be less than or equal to the search value.

### LessThanFilterType

[](#lessthanfiltertype)

The database value has to be less than the search value.

### LikeFilterType

[](#likefiltertype)

Will perform a like query on the given field.

### NotEqualFilterType

[](#notequalfiltertype)

The database value has to be different to the search value.

### NotInFilterType

[](#notinfiltertype)

The database value must not be in the given search values.

Todo
----

[](#todo)

- Options
    - Case sensititvity
    - Default value
- Distinct
- InstanceOf for multiple entities

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance58

Moderate activity, may be stable

Popularity24

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 99.2% 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 ~260 days

Recently: every ~700 days

Total

14

Last Release

270d ago

Major Versions

v0.3.0 → v1.0.02017-10-29

v1.0.2 → v2.0.02022-04-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/876f842b58e2a0e54d85eddfb8ed1b599586e94d9071efaddd208383ea85932c?d=identicon)[leo.viezens@web.de](/maintainers/leo.viezens@web.de)

---

Top Contributors

[![thmsu](https://avatars.githubusercontent.com/u/67536769?v=4)](https://github.com/thmsu "thmsu (132 commits)")[![LeoVie](https://avatars.githubusercontent.com/u/7249788?v=4)](https://github.com/LeoVie "LeoVie (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/queo-doctrine-filter/health.svg)

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[kimai/kimai

Kimai - Time Tracking

4.6k7.4k1](/packages/kimai-kimai)[damienharper/auditor

The missing audit log library.

1922.8M8](/packages/damienharper-auditor)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[forkcms/forkcms

Fork is an open source CMS that will rock your world.

1.2k44.5k](/packages/forkcms-forkcms)

PHPackages © 2026

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