PHPackages                             zenify/doctrine-filters - 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. zenify/doctrine-filters

Abandoned → [nettrine/orm](/?search=nettrine%2Form)Library[Database &amp; ORM](/categories/database)

zenify/doctrine-filters
=======================

Doctrine Filters integration into Nette

v4.5.0(5y ago)1319.6k[1 issues](https://github.com/Zenify/DoctrineFilters/issues)MITPHPPHP ^7.0

Since Sep 2Pushed 5y ago8 watchersCompare

[ Source](https://github.com/Zenify/DoctrineFilters)[ Packagist](https://packagist.org/packages/zenify/doctrine-filters)[ RSS](/packages/zenify-doctrine-filters/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (9)Versions (21)Used By (0)

Doctrine Filters
================

[](#doctrine-filters)

[![Build Status](https://camo.githubusercontent.com/9ceec87ab8c38194261ad04f569b84e79f66395f62cd704a27edb3efb42edb03/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f5a656e6966792f446f637472696e6546696c746572732e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Zenify/DoctrineFilters)[![Quality Score](https://camo.githubusercontent.com/b13b702b288cc7dcdc8e637f8bdb286b436e84c52e3a14b8791a89b1134fb971/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f5a656e6966792f446f637472696e6546696c746572732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Zenify/DoctrineFilters)[![Code Coverage](https://camo.githubusercontent.com/699bc43207100582f66c1d783a1c6987117a67919c93608385b2f710b3c8f830/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f5a656e6966792f446f637472696e6546696c746572732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Zenify/DoctrineFilters)[![Downloads](https://camo.githubusercontent.com/bf350b495835d2636c14ff213d4df60682da9d76136d67ddab6e3e5c7407d5c1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a656e6966792f646f637472696e652d66696c746572732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zenify/doctrine-filters)[![Latest stable](https://camo.githubusercontent.com/08834eb4bc92938e7069b6310b35653f1e66977f9ef08e7f8cf612956005a784/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a656e6966792f646f637472696e652d66696c746572732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zenify/doctrine-filters)

What are Doctrine Filters? Check [these few slides](https://speakerdeck.com/rosstuck/extending-doctrine-2-for-your-domain-model?slide=15) or see [Usage](#usage) to get the knowledge.

They are present in Doctrine by default. This package only simplifies their use in modular application.

Install
-------

[](#install)

```
$ composer require zenify/doctrine-filters
```

Register extension in `config.neon`:

```
extensions:
	- Zenify\DoctrineFilters\DI\FiltersExtension
	- Symplify\SymfonyEventDispatcher\Adapter\Nette\DI\SymfonyEventDispatcherExtension

	# Kdyby\Doctrine or another Doctrine to Nette implementation
```

Usage
-----

[](#usage)

Let's create our first filter, which will hide all deleted items on front. So called "soft delete" - data remains in database, but are filtered out in frontend.

First, we create class implementing [Zenify\\DoctrineFilters\\Contract\\FilterInterface](src/Contract/FilterInterface.php).

```
use Doctrine\ORM\Mapping\ClassMetadata;
use Zenify\DoctrineFilters\Contract\FilterInterface;

final class SoftdeletableFilter implements FilterInterface
{

	public function addFilterConstraint(ClassMetadata $entity, string $alias) : string
	{
		if ($entity->getReflectionClass()->hasProperty('isDeleted')) {
			return "$alias.isDeleted = 0");
		}

		return '';
	}

}
```

Then register as service:

```
# app/config/config.neon
services:
	- SoftdeletableFilter
```

And that's it!

### Limit Access by Role

[](#limit-access-by-role)

The management wants to show deleted content only to logged user with *admin* role.

To setup condition, we just implement [Zenify\\DoctrineFilters\\Contract\\ConditionalFilterInterface](src/Contract/ConditionalFilterInterface.php).

```
use Nette\Security\User;
use Zenify\DoctrineFilters\Contract\ConditionalFilterInterface;

final class SoftdeletableFilter implements ConditionalFilterInterface
{

	/**
	 * @var User
	 */
	private $user;

	public function __construct(User $user)
	{
		$this->user = $user;
	}

	public function addFilterConstraint(ClassMetadata $entity, string $alias) : string
	{
		// same as above
	}

	public function isEnabled() : bool
	{
		if ($this->user->isLoggedIn() && $this->user->hasRole('admin')) {
			return FALSE;
		}
		return TRUE;
	}

}
```

Voilá!

Testing
-------

[](#testing)

```
composer check-cs
vendor/bin/phpunit
```

Contributing
------------

[](#contributing)

Rules are simple:

- new feature needs tests
- all tests must pass
- 1 feature per PR

We would be happy to merge your feature then!

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~117 days

Recently: every ~346 days

Total

20

Last Release

2032d ago

Major Versions

v0.0.2 → v1.0.02014-09-02

v1.0.1 → v2.0.02014-11-22

v2.0.0 → v3.0.02014-12-17

v3.1.0 → v4.0.02015-06-11

PHP version history (4 changes)v2.0.0PHP &gt;=5.4

v3.0.0PHP &gt;=5.5

v4.0.0PHP &gt;=5.6

v4.1.0PHP ^7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/538058?v=4)[Milan Šulc](/maintainers/f3l1x)[@f3l1x](https://github.com/f3l1x)

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

---

Top Contributors

[![TomasPilar](https://avatars.githubusercontent.com/u/8326937?v=4)](https://github.com/TomasPilar "TomasPilar (6 commits)")[![TomasVotruba](https://avatars.githubusercontent.com/u/924196?v=4)](https://github.com/TomasVotruba "TomasVotruba (2 commits)")

---

Tags

deprecateddoctrinedoctrine-filtersfiltersphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zenify-doctrine-filters/health.svg)

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

###  Alternatives

[damienharper/auditor-bundle

Integrate auditor library in your Symfony projects.

4542.8M](/packages/damienharper-auditor-bundle)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[pixelfederation/doctrine-resettable-em-bundle

Symfony bundle for decorating default entity managers using a resettable decorator.

20113.5k](/packages/pixelfederation-doctrine-resettable-em-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.

1022.4k](/packages/rcsofttech-audit-trail-bundle)[ahmed-bhs/doctrine-doctor

Runtime analysis tool for Doctrine ORM integrated into Symfony Web Profiler. Unlike static linters, it analyzes actual query execution at runtime to detect performance bottlenecks, security vulnerabilities, and best practice violations during development with real execution context and data.

813.1k](/packages/ahmed-bhs-doctrine-doctor)

PHPackages © 2026

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