PHPackages                             pugx/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. pugx/filter-bundle

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

pugx/filter-bundle
==================

Utility for filtering/sorting with Symfony

v1.7.0(1mo ago)811.4k↓74.8%[1 issues](https://github.com/PUGX/filter-bundle/issues)[1 PRs](https://github.com/PUGX/filter-bundle/pulls)LGPL-3.0-or-laterPHPPHP ^8.1CI passing

Since Oct 31Pushed 1mo ago6 watchersCompare

[ Source](https://github.com/PUGX/filter-bundle)[ Packagist](https://packagist.org/packages/pugx/filter-bundle)[ RSS](/packages/pugx-filter-bundle/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (14)Versions (37)Used By (0)

PUGX FilterBundle
=================

[](#pugx-filterbundle)

[![Total Downloads](https://camo.githubusercontent.com/a713f5f3fadcb0037929933dcfc2511f2c2f4cb479170d5384e247ebe5ba2846/68747470733a2f2f706f7365722e707567782e6f72672f707567782f66696c7465722d62756e646c652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/pugx/filter-bundle)[![Build Status](https://github.com/PUGX/filter-bundle/workflows/Build/badge.svg)](https://github.com/PUGX/filter-bundle/actions)

The purpose of this bundle is to provide a way to get some filters that stay in session, to be able to use them when displaying a list of items. It also supports sorting.

Setup
-----

[](#setup)

Run

```
`composer require pugx/filter-bundle
```

No configuration is required.

Basic Usage
-----------

[](#basic-usage)

Inject the provided service in your controller and use it with a form.

Your form should use `GET` as method, use some fields that make sense on your list of items, and **not** use CSRF protection.

The first step is saving the filter with a name (if the form is submitted). Then, you can get a key/value array in `$filter->filter('foo')`, where "foo" is the name you provided above.

Using such an array to retrieve the filtered value is up to you: this bundle makes no assumptions about your domain and doesn't do magic.

Here is an example:

```
