jlm/serializer-expression-bundle
Integrates Symfony ExpressionLanguage with JMS Serializer so serialization metadata can use dynamic expressions for conditional exposure and exclusion. Lets API responses adapt to context, user roles, or runtime values without custom serialization code. Easy Symfony bundle setup.
ssn, internal cost, moderation state, or email unless the caller is authorized is a compliance-relevant behavior. A declarative, testable exclusion rule is easier to audit and evidence than ad-hoc if ($user->isAdmin()) checks. This is the strongest product argument for the pattern, independent of this specific package.$this->when(), whenLoaded(), $hidden/$visible) already cover the same need. Log this as a fit mismatch in our intake, alongside any other mis-routed Symfony packages.@Exclude(if="...")), Symfony Serializer (groups + #[Ignore] + normalization context), API Platform (serialization groups), or Laravel (API Resources with $hidden/$visible and conditional when* helpers). Also look elsewhere if the real requirement is per-caller payload shape at scale — that's better served by explicit read models/DTOs than by annotations on entities, which couples persistence to presentation.Executive summary: We evaluated jlm/serializer-expression-bundle, a small Symfony bundle that adds an expression-based @excludeIf annotation to JMS Serializer so fields can be conditionally omitted from API responses based on runtime context. Recommendation: do not adopt. It is archived with no maintainer, 4 GitHub stars, zero dependent projects, and a health score of 0.075. It is also a Symfony package, not applicable to our Laravel stack. Adopting it would create a permanent unpatched dependency for a capability our platform already provides natively.
For engineering: the capability is worth having; this implementation is not. Laravel API Resources already express conditional fields with closures that are typed, testable, and impossible to inject. Current JMS Serializer ships expression-based exclusion, and Symfony Serializer covers it with groups and callbacks. Cost of the alternative is a few hours of configuration or one read-model class. Cost of adoption is low in code and high in tail risk: vendor/fork overhead, no PHP 8 or modern Symfony compatibility, hot-path expression evaluation without caching, fail-open behavior that can silently leak excluded fields, and a migration we would have to fund ourselves.
The ask: close the evaluation as "capability covered by platform," add the pattern — declarative, context-aware, fail-closed field exclusion — to our serialization guidelines, and require an explicit owner plus exit plan for any future archived-dependency proposal of this shape.
How can I help you explore Laravel packages today?