symfony/object-mapper
Symfony Object Mapper component maps data from one object to another using PHP attributes. Simplifies DTO/entity transformations, supports configurable mapping rules, and integrates with the Symfony ecosystem. Documentation and contributions are handled in the main Symfony repository.
DependencyInjection, HttpFoundation, Messenger), making it ideal for Laravel projects already leveraging Symfony integrations (e.g., API Platform, HTTP clients, or DI containers).#[MapEntity], #[Ignore]) for declarative mapping, reducing boilerplate in controllers/services. Aligns with Laravel’s growing adoption of attributes (e.g., #[AsRequest], #[AsResponse] in API resources).CollectionTransformer, reducing manual recursion in mapping logic.DependencyInjection or standalone usage, avoiding framework lock-in.ObjectMapper as a singleton, replacing manual instantiation.#[AsRequest]) with minimal conflict risk.symfony/dependency-injection (e.g., via Laravel packages like spatie/laravel-symfony), the mapper can be auto-wired into services.#[MapProperty]) instead of traditional manual mapping, requiring training or documentation.spatie/laravel-data or manual mapping.ConditionCallableInterface). Mitigate by evaluating standalone alternatives if Symfony adoption is limited.nikic/php-parser)?Mapperly or JMS Serializer?spatie/laravel-data) more suitable?User) and DTOs (e.g., UserResponseDTO) in controllers/resources.OrderCreatedEvent → OrderCommand).ObjectMapper as a Laravel service for auto-wiring.symfony/http-foundation for request/response mapping.AppServiceProvider or a dedicated ObjectMapperServiceProvider.#[AsRequest]) by namespace isolation.UserEntity → UserDTO).UserController).#[MapEntity], #[Ignore]).ObjectMapper in Laravel’s DI container.array_map in controllers) with attribute-driven mapping.MapperHelper).JMS Serializer, spatie/laravel-data). Audit dependencies to avoid duplication.Callable or ObjectMapperAwareInterface, allowing integration with Laravel-specific logic (e.g., query scopes, accessors).composer require symfony/object-mapper.#[MapEntity] to DTOs and map source entities.#[MapProperty], #[Ignore], etc., for fine-grained control.ObjectMapper if needed).#[CacheAttributes] in Symfony 8+).laravel-object-mapper).ConditionCallableInterface).#[CacheAttributes]).Mapperly if performance is critical.How can I help you explore Laravel packages today?