api-platform-filters
Skill2 starsChanged 6 months agoMITView on GitHub
Build API Platform 4.3 filters with the modern `parameters` + `QueryParameter` pattern. Use when adding search, sort, range, full-text, or sparse-fieldset filtering to an operation. Covers `ExactFilter`, `PartialSearchFilter` (caseSensitive 4.3), `IriFilter` (nested), `UuidFilter` (4.3), `ComparisonFilter` (gt/gte/lt/lte/ne 4.3), `SortFilter` (nullsComparison), `FreeTextQueryFilter`, `OrFilter`, `ExistsFilter`, `BackedEnumFilter`, `PropertyFilter` (sparse, native 4.3), JSON:API `SparseFieldset`. Plus mandatory `property:` argument in 4.3, dot-notation nested, `castToNativeType` / `castToArray` / `castFn`, `strictQueryParameterValidation`, per-parameter security, Parameter Providers (IriConverter/ReadLink/custom), Doctrine SQL Filters for multi-tenant. **Never** `#[ApiFilter]` or `extends AbstractFilter` — legacy belongs to `api-platform-upgrade`.
In this repository52 other files it gives its agents.
- api-platform-dto-resourcesSkill
- api-platform-errorsSkill
- api-platform-file-uploadSkill
- api-platform-identifiersSkill
- api-platform-mcpSkill
- api-platform-mutatorsSkill
- api-platform-openapiSkill
- api-platform-paginationSkill
- api-platform-performanceSkill
- api-platform-resilienceSkill
- api-platform-resourcesSkill
- api-platform-securitySkill
- api-platform-serializationSkill
- api-platform-state-processorsSkill
- api-platform-state-providersSkill
- api-platform-testsSkill
- api-platform-upgradeSkill
- api-platform-userSkill
- api-platform-versioningSkill
- bootstrap-checkSkill
- brainstormingSkill
- config-env-parametersSkill
- controller-cleanupSkill
- cqrs-and-handlersSkill
- daily-workflowSkill
- doctrine-batch-processingSkill
- doctrine-fetch-modesSkill
- doctrine-fixtures-foundrySkill
- doctrine-migrationsSkill
- doctrine-relationsSkill
- doctrine-transactionsSkill
- effective-contextSkill
- executing-plansSkill
- functional-testsSkill
- interfaces-and-autowiringSkill
- makefile-disciplineSkill
- messenger-retry-failuresSkill
- ports-and-adaptersSkill
- quality-checksSkill
- rate-limitingSkill
- runner-selectionSkill
- strategy-patternSkill
- symfony-cacheSkill
- symfony-messengerSkill
- symfony-schedulerSkill
- symfony-votersSkill
- tdd-with-pestSkill
- tdd-with-phpunitSkill
- test-doubles-mockingSkill
- using-symfony-superpowersSkill
- value-objects-and-dtosSkill
- writing-plansSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
Add castToNativeType / castToArray / castFn where the value needs a type or transformation.
- Distinctive: line 27
Write tests that exercise each filter + boundary cases.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
API Platform 4.3 — Filters (modern parameters pattern)
Use when
- Adding any query filter, sort, range, or full-text search to a
GetCollection. - Replacing existing
#[ApiFilter]annotations (legacy) with the 4.3 modern pattern. - Implementing a custom filter via
FilterInterface+ Json Schema + OpenAPI traits. - Wiring a Parameter Provider (IRI converter, read link, custom dynamic group).
- Enforcing multi-tenant row-level security via a Doctrine SQL Filter.
Default workflow
- Identify the columns that must be filterable, sortable, or full-text searchable.
- Declare
parameters: [...]on the operation with onenew QueryParameter(filter: new XxxFilter(), property: '...')per parameter. - Add
castToNativeType/castToArray/castFnwhere the value needs a type or transformation. - Index every filtered column (
#[ORM\Index]) and a functional index for case-insensitive partial searches. - Write tests that exercise each filter + boundary cases.
Guardrails
propertyis mandatory in 4.3 onExactFilter,IriFilter,PartialSearchFilter,UuidFilter— otherwiseInvalidArgumentExceptionat compile time. Use the literal property name or the:propertyplaceholder.- Never use
#[ApiFilter]orextends AbstractFilterin new code — both are deprecated since 4.2 and removed in 5.0. IriFilterfor FKs, never anExactFilteron a scalaruserId(IRI-only rule).- Indexing is non-optional — without an index, a filter becomes a full scan.
PartialSearchFiltersparingly — a case-insensitive partial search bypasses btree indexes; add a functional index onLOWER(col)when used.
Progressive disclosure
SKILL.mdlists posture, the modern pattern, and rules.reference.mdcarries the full catalogue, dot-notation nested filters,FreeTextQueryFilter+OrFilter,ComparisonFilteroperators (incl.ne4.3),SortFilternullsComparison, custom filter recipe (interfaces + traits), Parameter Providers (4.3),PropertyFilternative (4.3), default global parameters, Doctrine SQL Filter for multi-tenant, and themake:filter orm/odmgenerator.
Output contract
parameters: [...]arrays on operations — no#[ApiFilter]left.- Tests asserting each filter against controlled data.
- Indices added on filtered columns (Doctrine
#[ORM\Index]). - Custom filters implement
FilterInterface,JsonSchemaFilterInterface,OpenApiParameterFilterInterface(with theOpenApiFilterTrait+BackwardCompatibleFilterDescriptionTrait).
References
reference.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

