mark-gerarts/automapper-plus-bundle
Symfony bundle integrating AutoMapperPlus for fast, configurable object-to-object mapping. Provides service wiring, profiles, and easy mapping between DTOs, entities, and view models with type safety and custom transformations.
symfony/dependency-injection, symfony/config) allows partial integration via standalone AutoMapper+ or custom bridge packages. However, native Laravel support is limited—this package is not a direct fit for Laravel without significant adaptation.spatie/laravel-data (DTOs with validation).collect($model)->toArray()).Model::resource() in Lumen).config/mappings.php vs. app/Mappings/).HasMany relations).| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Laravel-Symfony Friction | Symfony-specific features (e.g., ParameterBagConfigLoader) won’t work out-of-the-box. |
Use standalone AutoMapper+ (automapper/automapper-plus) instead of the bundle. |
| Performance Overhead | Reflection-based mapping may slow down Laravel’s high-throughput routes. | Benchmark against native Laravel collections or manual mapping. |
| Learning Curve | Team must learn AutoMapper+ syntax and Symfony integration patterns. | Start with standalone AutoMapper+ (simpler) before attempting the bundle. |
| Maintenance Burden | Custom Laravel integration may drift from upstream AutoMapper+ updates. | Pin to a stable version and isolate the integration layer. |
| Limited Laravel Ecosystem | No Laravel-specific docs, packages, or community support. | Leverage Symfony/Laravel crossover communities (e.g., API Platform users). |
array_map vs. Eloquent accessors)?spatie/laravel-data or native Laravel solutions meet needs with less friction?collect($model)->toArray()) is prioritized over mapping flexibility.| Phase | Task | Tools/Resources |
|---|---|---|
| Assessment | Audit current mapping patterns (manual, Eloquent, collections). | Static analysis (e.g., phpstan). |
| Pilot (Symfony Path) | If using Symfony components, test the bundle in a Symfony micro-app. | Use symfony/var-dumper for debugging. |
| Pilot (Standalone) | If Laravel-native, test AutoMapper+ core (automapper/automapper-plus). |
Follow AutoMapper+ Laravel guide. |
| Configuration | Define mappings in PHP classes (easiest for Laravel) or YAML (if Symfony-aligned). | Use automapper/automapper-plus:map CLI. |
| Laravel Integration | Create a Laravel service provider to bootstrap AutoMapper+. | Example: app/Providers/AutoMapperServiceProvider.php. |
| Testing | Write Pest/PHPUnit tests for mappings (mock dependencies). | Use AutoMapperTestCase or custom assertions. |
| Rollout | Replace manual mappings in controllers, services, and API resources. | Use feature flags for gradual adoption. |
| Monitoring | Track mapping performance (e.g., telescope for slow queries). |
Log mapping errors to laravel.log. |
composer require automapper/automapper-plus (standalone) or the bundle (Symfony path).User → UserDTO) work out-of-the-box.HasMany, MorphTo) need custom type converters.use AutoMapperPlus\AutoMapper;
use AutoMapperPlus\Configuration\Configuration;
$mapper = AutoMapper::getInstance();
$mapper->map()->entity(\App\Models\User::class, \App\DTO\UserDTO::class);
Order → OrderDTO).OrderDTO properties).setName($model->name) code.app/Mappings/).How can I help you explore Laravel packages today?