Please provide a migration path for the ApiFilter attribute => query parameter.
维护者通常 1 天内回复
@soyuka 已经在做这个了。
开始于 2025年11月30日。
评估
这个 Issue 还没有评估数据。
描述
Description
Hi @soyuka @vinceAmstoutz
I'm currently trying to migrate my ApiFilter attribute filters to avoid the futur deprecation, as explained in
https://api-platform.com/docs/core/doctrine-filters/#introduction
But I'm currently having big trouble to understand
- How to migrate some of my filters
- What's the benefit
And I feel like I'm maybe not the only one, looking at some recent issue/discussions.
Also I think this Upgrade note could explain with more details why this changes, cause currently I didn't found satisfying explanations.
I feel like the ApiFilter attribute will be replaced by
- The new filters classes (great)
- Declaring filter in the yaml/php config (why ? I hate having to maintain a config)
- Creating new dedicated filter (why having to maintain my own filter while ApiPlatform filters was doing the trick ?)
I understand writing doc is difficult and I'm open to do PR to improve it, but first I need to understand it ^^'
Example
I would expect a big list of BEFORE/AFTER example.
I'm unsure how to write it currently, based on the issues I encounter.
Problem I still have
- I have an OrderFilter
#[ApiFilter(OrderFilter::class, properties: ['name', 'createdAt'])]
that's I tried to migrated
parameters: ['order[:property]' => new QueryParameter(filter: new OrderFilter(), properties: ['name', 'createdAt'])],
it worked fine BUT got the same issue than https://github.com/api-platform/core/issues/7361
I follow the suggestion from soyuka (https://github.com/api-platform/core/issues/7361#issuecomment-3243315889) to use service id with .instance
parameters: ['order[:property]' => new QueryParameter(filter: 'api_platform.doctrine.orm.order_filter.instance', properties: ['name', 'createdAt'])],
but then the filter does nothing as reported by https://github.com/api-platform/core/issues/7361#issuecomment-3240681163
Looking at https://github.com/api-platform/core/issues/7361#issuecomment-3243835860 I feel like I'll have to declare a new service in my config. Is it the only way ? Is it plan to introduce a new OrderFilter ?
- I have a filter with nested property
#[ApiFilter(SearchFilter::class, properties: ['languagePair.target' => 'exact'])]
As reported https://github.com/api-platform/core/pull/7121#issuecomment-3575382644 and answered by soyuka, nested properties are (voluntary) not supported anymore for those filters.
This is already discussed in https://github.com/api-platform/core/issues/7526
Filtering on nested properties requires joins which is hard to predict and may lead to unwanted behavior / performance issues, can't you create your own filter?
I have a big trouble understanding
- What was the issue before (since it works)
- How my own filter will avoid this issue (since I'll have to make my own JOIN !)
Wouldn't it be possible to still support nested properties ? Or to do somehting like OrFilter:
new NestedFilter(new ExactFilter())
Also soyuka told me I can still use the legacy (not recommended) SearchFilter but I got the same issue than the OrderFilter, something like
parameters: [
'targetLanguage' => new QueryParameter(
filter: 'api_platform.doctrine.orm.search_filter.instance',
property: 'languagePair.target'
),
]
does nothing...
Problem solved that might help someone else...
- I have a BooleanFilter on a live property I tried to migrate to
parameters: ['live' => new QueryParameter(filter: new BooleanFilter(), property: 'live')],
it worked fine BUT got the same issue than https://github.com/api-platform/core/issues/7361
I'm finally solve my issue with
parameters: ['live' => new QueryParameter(filter: new ExactFilter(), property: 'live')],
but I'm not sure of the changes.
- I have a SearchFilter
#[ApiFilter(SearchFilter::class, properties: ['name' => 'partial'])]
that I migrated into
parameters: ['name' => new QueryParameter(filter: new PartialSearchFilter(), property: 'name')],
I feel like it's the right way to do it.
- 主要语言
- PHP
- 星标
- 2.6k
- 派生
- 989
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 102
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
api-platform/core 的其他 Issue
-
JSON:API: resource schemas (`*.jsonapi`) have `properties` but no `type: object`可能已有人在做 @ousamabenyounes 于 1 天前认领。 未关闭
难度 2/5 1 小时以内 新手友好度 80/100
api-platform/core#8701 ·
维护者通常 1 天内回复
-
JSON:API: `JsonApiCollectionBaseSchemaNoPagination` declares `data` as `type: array` without `items`未关闭
难度 2/5 1-3 小时 新手友好度 82/100
api-platform/core#8699 ·
维护者通常 1 天内回复
-
api:openapi:export --spec-version=3.0.0 outputs `webhooks`, which is invalid in OpenAPI 3.0可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
api-platform/core#8690 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
api-platform/core#8680 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 68/100
api-platform/core#8725 ·
维护者通常 1 天内回复
查看 api-platform/core 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 88/100
grokability/snipe-it#19857 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 92/100
维护者通常 1 天内回复
-
Authentication / Authorization Feature: Volunteer
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 64/100
WordPress/mcp-adapter#399 ·
维护者通常 1 天内回复