Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Object Mapper Laravel Package

symfony/object-mapper

Symfony Object Mapper maps data between objects (e.g., DTOs to entities) using PHP attributes to define field mappings. It reduces boilerplate transformation code, supports configurable mapping logic, and integrates cleanly with Symfony applications.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Symfony Ecosystem Integration:

    • Adopt this package to standardize object-to-object mapping in Symfony applications, particularly for projects leveraging Symfony 8.4+ and attribute-driven architectures (e.g., API Platform, Symfony UX). It aligns with Symfony’s declarative programming model, reducing manual mapping logic and improving maintainability.
    • Ideal for layered architectures (e.g., API → Application → Domain layers) where DTOs, commands, and queries require consistent transformation rules.
  • Build vs. Buy Decision:

    • Buy for Symfony: Eliminate custom mapper development by adopting this batteries-included solution for complex object graphs, nested mappings, and conditional logic. Justify adoption if your team is already invested in Symfony’s attribute system (e.g., [Map], [Ignore]).
    • Build for Laravel: Avoid this package. Laravel’s ecosystem offers better alternatives (e.g., Spatie Data Transfer Objects, Fractal, or custom mappers) that avoid Symfony dependency lock-in and PHP 8.4+ constraints. Building a lightweight, framework-agnostic mapper may be more future-proof.
  • Roadmap Alignment:

    • Symfony Upgrades: If your roadmap includes migrating to Symfony 8.4+, this package can accelerate DTO development and reduce technical debt in data transformation layers. Its integration with Symfony’s attribute system makes it a natural fit for domain-driven design (DDD) or clean architecture projects.
    • Laravel Roadmap: Do not adopt. This package introduces unnecessary constraints (e.g., PHP version, Symfony dependency) that conflict with Laravel’s native tools. Prioritize Laravel-specific solutions to maintain flexibility.
  • Feature Prioritization:

    • Justify adoption if:
      • Your project requires advanced mapping features (e.g., nested objects, conditional logic, collection transformations) and is committed to Symfony 8.4+.
      • You want to centralize mapping rules using attributes (e.g., [Map], [Ignore]) for self-documenting code.
      • You are building a shared library or microservice within a Symfony ecosystem where this component’s capabilities (e.g., lazy loading, collection transformers) are critical.
    • Avoid for:
      • Simple DTOs or API responses where Spatie DTOs or Fractal suffice.
      • Projects with legacy PHP versions (pre-8.4) or non-Symfony frameworks.
      • Teams preferring minimal dependencies or framework-agnostic solutions.

When to Consider This Package

Adopt this package if:

  1. You are fully committed to Symfony 8.4+ and require attribute-based object mapping for DTOs, commands, or API responses.
  2. Your team prefers Symfony’s Object Mapper over the Serializer due to:
    • Performance: Avoiding JSON serialization overhead for internal transformations.
    • Flexibility: Support for nested objects, conditional logic, and collection transformations.
    • Explicit intent: Attribute-driven mapping rules reduce ambiguity in data flow.
  3. You need advanced mapping features, such as:
    • Nested object transformations (e.g., UserUserDTO with embedded AddressDTO).
    • Conditional mapping (e.g., skipping fields based on business rules or runtime conditions).
    • Collection-to-collection mapping (e.g., array<User>Collection<UserDTO>).
  4. You are willing to upgrade to PHP 8.4+ and accept the Symfony dependency lock-in.
  5. You are building a Symfony microservice or shared library where this component’s features justify the dependency.

Avoid this package if:

  • You are using Laravel, WordPress, or non-Symfony PHP frameworks. Laravel has native alternatives (e.g., Spatie Data Transfer Objects, Fractal) that integrate seamlessly.
  • Your project cannot upgrade to PHP 8.4+ due to legacy constraints, hosting limitations, or team expertise.
  • Your use case is simple (e.g., basic DTOs or API responses). This package is overkill for lightweight needs and introduces unnecessary complexity.
  • You prefer Laravel-native tools for better integration, lower maintenance risk, and framework alignment.
  • You are not using Symfony’s attribute system (e.g., [Map] annotations) and want to avoid boilerplate or attribute-based configurations.
  • You require immediate stability—this package has zero dependents, minimal adoption, and a history of experimental features (e.g., previously part of Symfony’s experimental components).

How to Pitch It (Stakeholders)

For Executives:

*"The Symfony Object Mapper is a Symfony-specific tool designed to automate object-to-object transformations using attributes. While powerful for Symfony applications, it is not compatible with Laravel due to PHP 8.4+ requirements and Symfony dependency lock-in.

Key Considerations:

  • Symfony Migration: If your roadmap includes adopting Symfony 8.4+, this package can reduce development time for DTOs, commands, and API responses by eliminating manual mapping logic. It aligns with Symfony’s attribute-driven architecture, improving code maintainability.
  • Laravel Projects: Do not adopt. Laravel offers better alternatives (e.g., Spatie Data Transfer Objects, Fractal) that are lightweight, framework-native, and require no PHP upgrades. Adopting this package would introduce unnecessary technical debt and vendor lock-in.
  • Long-Term Risk: This package has zero Laravel adoption, no community support outside Symfony, and a history of experimental features, raising concerns about long-term viability and maintenance.

Recommendation:

  • For Symfony Projects: Adopt only if migrating to Symfony 8.4+ and needing advanced mapping features. Evaluate whether the Symfony ecosystem benefits outweigh the dependency risks.
  • For Laravel Projects: Skip entirely. Use Spatie DTOs or Fractal to maintain flexibility and framework alignment.

Critical Question: Does the Symfony migration ROI justify adopting this package? If not, prioritize Laravel-compatible solutions to keep the stack agile and future-proof."*


For Engineering Teams:

*"Symfony Object Mapper is a Symfony-only solution and not suitable for Laravel. Here’s how to evaluate it:

Pros (Symfony Only):

  • Reduces boilerplate: Automates DTO, command, and query transformations using attributes (e.g., [Map], [Ignore]).
  • Supports complex mappings: Handles nested objects, conditional logic, and collections out of the box.
  • Performance: Avoids JSON serialization overhead for internal transformations.
  • Integration: Works seamlessly with Symfony 8.4+, API Platform, and Symfony UX.

Cons (Critical for Laravel):

  • Symfony dependency: Locks you into Symfony’s ecosystem, making it incompatible with Laravel.
  • PHP 8.4+ requirement: Blocks adoption for projects on older PHP versions.
  • Minimal adoption: Zero dependents outside Symfony, raising concerns about long-term support.
  • Overkill for simple use cases: Adds complexity for basic DTOs where Spatie DTOs or Fractal suffice.

When to Use It:

  • You’re fully committed to Symfony 8.4+ and need advanced mapping features.
  • Your project uses Symfony’s attribute system and requires centralized transformation rules.
  • You’re building a Symfony microservice where this component’s capabilities are critical.

When to Avoid It:

  • You’re using Laravel, WordPress, or non-Symfony frameworks.
  • Your project cannot upgrade to PHP 8.4+.
  • You prefer lightweight, framework-agnostic solutions (e.g., Spatie DTOs, Fractal).
  • Your use case is simple and doesn’t justify the Symfony dependency.

Alternatives for Laravel:

  • Spatie Data Transfer Objects: Lightweight, Laravel-native DTOs.
  • Fractal: Flexible API resource transformation.
  • Custom mappers: For full control over mapping logic.

Recommendation:

  • Symfony teams: Adopt if aligned with your Symfony 8.4+ roadmap and mapping complexity.
  • Laravel teams: Avoid. Use Spatie DTOs or Fractal instead to maintain flexibility and framework compatibility."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4