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.
User ↔ UserResponseDTO), reducing boilerplate in controllers and services. Example: Replace return new UserResponseDTO($user->name, $user->email) with @MapEntity attributes, enforcing consistency across the codebase.string → Carbon).array_map or create() chains in controllers with attribute-driven mapping (e.g., @MapProperty, @Ignore).User tables to UserProfileDTO).UserFactory → User).OrderCreatedEvent → OrderCommand).Request → UserUpdateCommand).Adopt if:
string → DateTime).setName() chains in controllers).@MapEntity, @Ignore) to reduce boilerplate.symfony/dependency-injection or symfony/http-client).Look elsewhere if:
Model::find() → json_encode()).spatie/laravel-data or php-http/message for tighter integration.symfony/serializer instead).fill() or create()).For Executives:
"This package reduces API development time by 50% by automating the manual mapping between database records, internal objects, and API responses. For example, converting a UserEntity to a UserResponseDTO—which today requires 20+ lines of boilerplate—can be done in 2 lines with attributes. This directly supports our goals to [reduce technical debt and accelerate feature delivery] while keeping code clean and maintainable. It’s a low-risk, high-reward choice, backed by Symfony’s stability, and MIT-licensed for full flexibility. The ROI comes from faster iterations, fewer bugs, and easier maintenance in our API layer."
For Engineers:
"Symfony’s Object Mapper lets us replace repetitive mapping logic with declarative attributes (e.g., @MapEntity, @Ignore), cutting cognitive load and runtime errors. It integrates seamlessly with Laravel’s DI system (via symfony/dependency-injection) and supports nested objects/collections out of the box. For teams using Symfony components or PHP 8+, this is a no-brainer—it’s battle-tested, actively maintained, and avoids reinventing the wheel. If we’re not using Symfony, we could evaluate alternatives like spatie/laravel-data, but this gives us the most ‘batteries-included’ experience for complex mappings. It’s especially useful for APIs, DDD, or legacy integrations where object transformation is a pain point."
For Architects: *"This package aligns with clean architecture principles by enforcing separation between domain models and API contracts. Key benefits include:
How can I help you explore Laravel packages today?