PHPackages                             bukashk0zzz/filter-bundle - 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. [Search &amp; Filtering](/categories/search)
4. /
5. bukashk0zzz/filter-bundle

ActiveSymfony-bundle[Search &amp; Filtering](/categories/search)

bukashk0zzz/filter-bundle
=========================

Symfony filter bundle.

v5.0.1(3y ago)24459.9k↓48.5%5[1 PRs](https://github.com/Bukashk0zzz/FilterBundle/pulls)1MITPHPPHP &gt;=8.0.0

Since Mar 16Pushed 2y ago4 watchersCompare

[ Source](https://github.com/Bukashk0zzz/FilterBundle)[ Packagist](https://packagist.org/packages/bukashk0zzz/filter-bundle)[ Docs](https://github.com/bukashk0zzz/FilterBundle)[ RSS](/packages/bukashk0zzz-filter-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (22)Used By (1)

Symfony Filter Bundle
=====================

[](#symfony-filter-bundle)

[![Code Coverage](https://camo.githubusercontent.com/088ce456c268459a218e5db6f7eb8e1cf2ab4f13f15cdbb7f105e8ec2ca63b40/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f42756b6173686b307a7a7a2f46696c74657242756e646c652e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/github/Bukashk0zzz/FilterBundle)[![License](https://camo.githubusercontent.com/302ed5f5ff528c1d85904a5b595ac17d637e7a724e666cae68cbf0579abed240/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f42756b6173686b307a7a7a2f66696c7465722d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/Bukashk0zzz/filter-bundle)[![Latest Stable Version](https://camo.githubusercontent.com/6459fdab2ad6380d89e0a56f9ee6caf21f419a6145aa856449800e28ad9c76e0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f42756b6173686b307a7a7a2f66696c7465722d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/Bukashk0zzz/filter-bundle)[![Total Downloads](https://camo.githubusercontent.com/65aa46afaafcf9c2a7f6d6a4ae425101e291498789fb7192f518e1d4a24a5309/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f42756b6173686b307a7a7a2f66696c7465722d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/Bukashk0zzz/filter-bundle)

About
-----

[](#about)

This bundle add a service that can be used to filter object values based on annotations. [Laminas filter](https://github.com/laminas/laminas-filter) old [ZendFilters](https://github.com/zendframework/zend-filter) used for filtering. Also bundle can filter your forms if it finds a annotated entity attached. If `auto_filter_forms` enabled entities will be filtered before they are validated. [Laminas filters doc](https://docs.laminas.dev/laminas-filter/)

Installation Symfony Flex
-------------------------

[](#installation-symfony-flex)

```
composer config extra.symfony.allow-contrib true
composer require bukashk0zzz/filter-bundle
```

Installation without Symfony Flex
---------------------------------

[](#installation-without-symfony-flex)

```
composer require bukashk0zzz/filter-bundle
```

Add the bundle to `app/AppKernel.php`

```
$bundles = array(
	// ... other bundles
	new Bukashk0zzz\FilterBundle\Bukashk0zzzFilterBundle(),
);
```

Configuration
-------------

[](#configuration)

Add this to your `config.yml`:

```
bukashk0zzz_filter:
    # Enable if you need auto filtering form data before constraint(Validation) check
    auto_filter_forms: false
```

Usage
-----

[](#usage)

Bundle provides one annotation which allow filter fields in your entities.

Add the next class to the `use` section of your entity class.

```
use Bukashk0zzz\FilterBundle\Annotation\FilterAnnotation as Filter;
```

Annotation `@Filter` has one required option *filter* which value should be name of Laminas filter class. It can be set like this `@Filter("StringTrim")` or `@Filter(filter="AppBundle\Filter\MyCustomFilter")`.

`AppBundle\Filter\MyCustomFilter` - in this example, must be class that extends `\Laminas\Filter\AbstractFilter`

Also there is one not required option `options` - it must be array type and will pass to Laminas filter using `setOptions` method from Laminas filter.

Example entity
--------------

[](#example-entity)

```
