JMSSerializerBundle

Symfony integration bundle for JMS Serializer, wiring configurable JSON/XML/YAML (de)serialization into the framework's DI container

Library
Composer
v5.5.2
1,807stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
51/100Fair
Development Activity8
Maintenance32
Community76
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
63/100Good
Architecture70
Code Quality70
Innovation58
Learning Curve55

JMSSerializerBundle integrates the standalone jms/serializer library into Symfony applications, exposing its powerful, annotation/attribute-driven serialization engine as a configured service inside the framework’s dependency-injection container. It handles arbitrarily complex object graphs — nested objects, collections, polymorphic types, virtual properties — and serializes them to JSON, XML, or YAML with fine-grained control over property exposure, versioning, and grouping.

The bundle predates Symfony’s own Serializer component and remains widely used where teams need capabilities the core component doesn’t offer as directly, such as expression-language-based property exclusion, deep customization of (de)serialization contexts, and long-standing annotation-based metadata that many legacy Symfony codebases already depend on.

What You Get

  • Symfony DI integration for jms/serializer, configurable via config/packages/jms_serializer.yaml
  • Annotation and PHP-attribute based mapping for exclusion strategies, groups, versions, and virtual properties
  • Serialization to JSON, XML, and YAML from the same object metadata
  • Doctrine integration for lazy-loading proxies and entity metadata during serialization
  • Symfony ExpressionLanguage support for conditional property exclusion rules

Common Use Cases

  • Serializing complex Doctrine entity graphs (nested relations, collections) to API JSON responses with fine-grained field control
  • Supporting multiple API versions from one set of models via version-based property exclusion groups
  • Migrating legacy Symfony 2/3 applications that already depend on JMS annotations without a full serializer rewrite
  • Producing XML or YAML representations of the same domain objects alongside JSON for interoperability with older clients

Under The Hood

Architecture JMSSerializerBundle.php and DependencyInjection/ register the standalone jms/serializer library’s SerializerBuilder as Symfony services, exposing its metadata-driven serialization pipeline (annotation/attribute readers → metadata factory → format-specific visitors) through the framework’s config tree; ContextFactory/ builds per-request serialization/deserialization contexts, and Serializer/ adds Symfony-specific handlers (e.g. Doctrine proxy unwrapping, form error serialization via Templating/).

Tech Stack PHP bundle requiring jms/serializer ^3.31 and jms/metadata ^2.6 as the core engine, layered onto Symfony 5.4–8.0 (framework-bundle, dependency-injection, config); optional dev dependencies include Doctrine ORM and Symfony ExpressionLanguage/Form for extended integration.

Code Quality A dedicated Tests/ tree with PHPUnit covers the DI extension, context factory, and serializer handlers; CHANGELOG.md and UPGRADING.md document breaking changes across major versions, consistent with a long-lived, widely-depended-on Symfony ecosystem bundle.

API Design Configuration happens through Symfony’s standard bundle config (config/packages/jms_serializer.yaml) plus per-property annotations/attributes on model classes, which is idiomatic for Symfony but requires learning JMS’s specific annotation vocabulary (@Exclude, @Groups, @Since/@Until) — a moderate learning curve, especially for teams coming from Symfony’s own Serializer component with different attribute names.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search