polysource / filter
Polysource — standalone filter primitive: form/datasource separation, session persistence, mapper/formatter/renderer pipeline, multi-mode UI (integrated, subpanel) with chips bar.
Package info
Type:symfony-bundle
pkg:composer/polysource/filter
Requires
- php: >=8.2
- polysource/core: ^0.1 || ^0.2 || ^0.3 || ^0.4 || ^0.5 || ^0.6 || ^0.7 || ^0.8 || ^0.9 || ^0.10 || ^0.11 || ^1.0
- symfony/config: ^6.4 || ^7.0 || ^8.0
- symfony/dependency-injection: ^6.4 || ^7.0 || ^8.0
- symfony/event-dispatcher: ^6.4 || ^7.0 || ^8.0
- symfony/form: ^6.4 || ^7.0 || ^8.0
- symfony/http-foundation: ^6.4 || ^7.0 || ^8.0
- symfony/http-kernel: ^6.4 || ^7.0 || ^8.0
- symfony/translation: ^6.4 || ^7.0 || ^8.0
- symfony/yaml: ^6.4 || ^7.0 || ^8.0
- twig/twig: ^3.0
Requires (Dev)
- phpunit/phpunit: ^10.5 || ^11.5
- symfony/browser-kit: ^6.4 || ^7.0 || ^8.0
- symfony/dom-crawler: ^6.4 || ^7.0 || ^8.0
- symfony/framework-bundle: ^6.4 || ^7.0 || ^8.0
- symfony/phpunit-bridge: ^6.4 || ^7.0 || ^8.0
- symfony/twig-bundle: ^6.4 || ^7.0 || ^8.0
Suggests
- doctrine/orm: Enables the Doctrine-backed storages (saved views, column preferences, bulk-action history, filter URL tokens). Gated on the ORM being installed; session/in-memory storages are used when absent.
This package is auto-updated.
Last update: 2026-08-07 15:37:53 UTC
README
Filter primitives for Symfony admin UIs — usable standalone in any Symfony app, also the foundation of
polysource/easyadmin-filter-bridgeandpolysource/symfony-bundle.
Part of the Polysource monorepo. MIT-licensed.
What it ships
-
FilterCollection+FilterCriterion— immutable value objects representing the active filter state, scoped by a stableid(typically the resource FQCN). -
FilterService— session-backed persistence (load / save / clear per resource). -
FilterCollectionTypeform type +FilterHydrator— bind a whole filter collection to a Symfony form and hydrate it back into criteria. (The enhanced EasyAdmin form types — date presets, between, in, full-text — live inpolysource/easyadmin-filter-bridge, not here.) -
The mapping pipeline —
FilterMapperInterface/FilterFormatterInterface/FilterRendererInterfaceplus their registries and a default triplet per filter kind (text, numeric, boolean, choice, datetime, entity, array-list). This is the URL → criteria → form → chip road, and every leg of it is swappable. -
Twig extension
filter_tags— renders the active-filters chips bar. -
Saved views —
SavedViewVO +SavedViewService+ Doctrine + in-memory storage adapters + Symfony voter for scope-aware visibility (private / team / public). See ADR-019. -
SavedViewExtensionTwig extension — renders the dropdown. -
Column preferences —
ColumnPreferenceService+ Doctrine / in-memory storage + Twig extension: per-user column visibility and ordering. -
Filter URL tokens —
FilterUrlTokenService+ storage, turning a long filter query into a short shareable link, with apolysource:filter-url-tokens:purgecommand for retention. -
Recent records —
RecentRecordsService+ storage, the "recently viewed" trail per user. -
Bulk action history —
BulkActionHistoryService+ storage +polysource:bulk-action-history:purge, an append-only log of bulk runs. -
Two Stimulus controllers under
assets/controllers/, advertised throughassets/package.jsonso AssetMapper and Encore + StimulusBundle pick them up automatically:polysource--filter-chips— chips-bar interactions.polysource--row-details— the expandable row-details panel. It ships from this package and is shared by both the EasyAdmin bridge and the nativepolysource/symfony-bundlelisting.
Both are progressive enhancement only: without a JS pipeline the server-rendered behaviour stands (per ADR-027).
Audience
Standalone usage targets:
- Sonata users wanting better filter UX
- API Platform back-offices
- Hand-rolled admin DIY
- Any Symfony app that builds filter forms manually
For EasyAdmin v5 hosts, install polysource/easyadmin-filter-bridge instead — it wraps this package with auto-discovery.
Install
composer require polysource/filter
Register the bundle in config/bundles.php:
return [ Polysource\Filter\PolysourceFilterBundle::class => ['all' => true], ];
Extend it
| Need | Implement |
|---|---|
| Persist saved views in Redis / Mongo / your HTTP service | SavedViewStorageInterface (4 methods: save / find / listVisible / delete) |
| Resolve which "team" a user belongs to (for shared views) | SavedViewTeamResolverInterface (1 method) |
| Format a chip your way ("3 statuses" instead of "paid, shipped, …") | ChipFormatterInterface (1 method, ADR-016) |
| Take over the URL → criteria → form pipeline | FilterMapperInterface / FilterFormatterInterface / FilterRendererInterface |
See the full extensibility map.