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

Object Mapper Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Provides a way to map an object to another object

Frequently asked questions about Object Mapper
Can I use Symfony Object Mapper in Laravel without Symfony’s full stack?
No, this package requires Symfony components like `symfony/attribute` and `symfony/property-access`, which introduce dependency conflicts with Laravel’s `illuminate/support`. Even with PHP 8.4+, you’d need manual shimming or polyfills, making it impractical for most Laravel projects.
What’s the minimum PHP version required for Symfony Object Mapper?
PHP 8.4+. Laravel projects often use PHP 8.1–8.3, so upgrading just for this package may not be worth the effort unless you’re already committed to Symfony 8.4+. Check your Laravel version’s supported PHP range first.
How does Symfony Object Mapper compare to Spatie’s DTO package for Laravel?
Spatie’s DTO package is lightweight, Laravel-native, and avoids Symfony dependencies entirely. It handles basic mapping without attributes, while Symfony’s mapper adds complexity (attributes, Symfony DI) that Laravel doesn’t need. Spatie is the clear winner for Laravel.
Does Symfony Object Mapper support nested object mapping (e.g., DTOs inside DTOs)?
Yes, it supports nested mappings via attributes like `[Map]` and custom logic. However, in Laravel, you’d still face Symfony dependency issues, and alternatives like Fractal or custom mappers can achieve the same without vendor lock-in.
Will Symfony Object Mapper work with Laravel’s Eloquent models?
Technically, it could map Eloquent models to DTOs, but the Symfony dependency (`symfony/property-access`) may conflict with Laravel’s `illuminate/support`. The overhead isn’t justified—Laravel’s native casting or Spatie’s DTOs are simpler solutions.
Can I use Symfony Object Mapper for API request/response transformations?
Yes, but only in Symfony apps. For Laravel, Fractal or Laravel’s built-in JSON responses are better choices. Symfony’s mapper adds unnecessary complexity (attributes, Symfony DI) that Laravel APIs don’t require.
How do I configure custom value transformations in Symfony Object Mapper?
Use the `@Map` attribute with `type: 'method'` or `type: 'service'` to define custom logic. However, in Laravel, you’d need to manually register Symfony services in Laravel’s container, which is error-prone and not recommended.
Does Symfony Object Mapper integrate with Laravel’s service container?
No, it’s designed for Symfony’s DI container. Laravel’s container uses a different structure, and binding Symfony services would require custom bootstrapping—far more work than using Laravel-native tools like Spatie’s DTOs.
What are the performance implications of using Symfony Object Mapper in Laravel?
Symfony’s mapper relies on reflection and attributes, which can bloat autoloading and runtime performance. Laravel’s native solutions (e.g., Spatie DTOs) are optimized for PHP’s lower-level operations and avoid Symfony’s overhead.
Are there Laravel-compatible alternatives to Symfony Object Mapper?
Yes: **Spatie’s DTO package** (lightweight, no dependencies), **Fractal** (API serialization), or **custom mappers** (for full control). These avoid Symfony’s lock-in and work seamlessly with Laravel’s architecture.
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai