Weave 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 maps one object to another using PHP attributes, giving you a clean, declarative way to handle DTOs and transformations without boilerplate. Part of the Symfony ecosystem.

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 a Laravel application?
Yes, but it is a Symfony component with no Laravel integration. You can install it via Composer and manually construct the mapper in a service provider. Expect to own the wiring, transformer registration, and metadata caching yourself.
How do I install symfony/object-mapper in Laravel?
Run composer require symfony/object-mapper and choose a version compatible with your PHP runtime. The 7.4 line targets PHP 8.2 and 8.3, while 8.x requires PHP 8.4. There is no Laravel package discovery or config file, so installation is just the library.
Does symfony/object-mapper include a Laravel service provider or facade?
No. The component ships no service provider, config file, facade, or Eloquent awareness. Symfony's normal integration relies on its DI compiler pass to autoconfigure attributes, which Laravel does not run. In Laravel you must register the MappingConfiguration and mapper instance yourself.
Which Laravel and PHP versions work with symfony/object-mapper?
The package is not tied to a Laravel version, but PHP compatibility drives your choice. Use the 7.4 branch on PHP 8.2 or 8.3, which covers most Laravel 11 and 12 estates. The 8.x branch requires PHP 8.4, so confirm your runtime before committing.
Can symfony/object-mapper map Eloquent models to DTOs?
Yes, but Eloquent is where the sharp edges are. Models expose attributes through magic __get and __isset plus casts, not declared typed properties, so the mapper may encounter lazy values, Carbon casts, or appended accessors. Mapping plain DTOs and domain objects is lower risk; test Eloquent sources thoroughly.
How do I register custom transformers and conditions in Laravel?
You register them manually on the MappingConfiguration or mapper instance inside a service provider. Symfony would normally discover attribute-based transforms through its compiler pass, but Laravel's container does not run that pass. Budget roughly 50 to 150 lines for a one-time integration.
Does symfony/object-mapper work with Laravel Octane?
There is no Laravel-specific Octane documentation or support. Because metadata discovery and mapper construction are manual, you need to decide how to cache or rebuild metadata safely across workers. Treat Octane compatibility as an integration concern you must test, not a documented guarantee.
Is symfony/object-mapper stable enough for production?
Governance risk is low: it is MIT licensed, maintained by the Symfony core team, and follows a predictable release train. Maturity risk is medium because the component only left experimental status in the 7.4 and 8.0 cycle, and changelogs still show behavioral bugfixes around object graph traversal. Use it where DTO mapping is well bounded and cover it with tests.
What are alternatives to symfony/object-mapper for Laravel DTO mapping?
Hand-written factory methods like User::fromModel() remain the simplest option and avoid extra dependencies. Laravel-focused mapping or DTO packages and serializers may offer more ecosystem-friendly wiring. Choose symfony/object-mapper when you want attribute-driven declarative mapping and accept owning the integration.
How should I test object mappings in a Laravel app?
Write feature or unit tests that construct the mapper exactly as your service provider does, then assert source-to-target output. Include edge cases such as missing source properties, uninitialized values, nested objects, and Eloquent casts. Since Laravel-specific docs do not exist, your tests become the contract for the integration.
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.
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core