This repository demonstrates a bug in API Platform where the built-in BackedEnumFilter
does not support integer-backed enums.
It includes a minimal Symfony application pre-configured to showcase both the broken behavior and a custom workaround that resolves the issue.
Start the Symfony server:
symfony serve
Once running, access the API docs at:
The SQLite database (var/data_dev.db
) is pre-populated with dummy objects for testing.
-
Visit the
DummyUsingCurrentFilter
resource. -
Try filtering using the
dummyIntBackedEnum
property. -
You'll see that filtering does not work.
-
Symfony logs a warning:
Invalid filter ignored.
This is because the default BackedEnumFilter
does not properly handle enums backed by integers.
- The
DummyUsingUpdatedFilter
resource uses a customBackedEnumFilter
andBackedEnumFilterTrait
located insrc/ApiFilter
. - This custom implementation properly handles integer-backed enums.
- Filtering now works as expected.
src/Entity/
– Demo entitiessrc/ApiFilter/
– Custom filter and trait for enum supportvar/data_dev.db
– Pre-filled SQLite DB for quick testing