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

Automapper Plus Bundle Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Laravel Compatibility: While this is a Symfony bundle, Laravel’s Symfony components compatibility (e.g., 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.
  • Use Case Alignment:
    • Ideal for Symfony-heavy Laravel apps (e.g., using Laravel with Symfony components like API Platform).
    • Less suitable for vanilla Laravel due to missing Laravel-specific integrations (e.g., Eloquent, Laravel Collections).
  • Alternatives in Laravel:
    • spatie/laravel-data (DTOs with validation).
    • Native Laravel collections (collect($model)->toArray()).
    • Manual mapping (e.g., Model::resource() in Lumen).
  • Key Tradeoff: Symfony-native features (e.g., YAML config, DI integration) may not translate cleanly to Laravel’s ecosystem.

Integration Feasibility

  • Symfony Dependency: Requires Symfony’s container, config system, and event dispatcher. Laravel’s Pimple container or Laravel’s DI would need workarounds (e.g., wrapping AutoMapper+ in a Laravel service).
  • Configuration Overhead:
    • YAML/XML/annotations may clash with Laravel’s PHP-first conventions (e.g., config/mappings.php vs. app/Mappings/).
    • No built-in Laravel service provider—would need custom bootstrapping.
  • ORM Support:
    • Works with Doctrine, but Eloquent mappings would require custom type converters (e.g., handling HasMany relations).
  • Testing Complexity:
    • Laravel’s PHPUnit + Pest would need adapters for AutoMapper+’s test utilities.

Technical Risk

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).

Key Questions

  1. Laravel vs. Symfony Priority:
    • Is the project primarily Symfony (e.g., API Platform, Symfony UX) or Laravel-native?
    • Would standalone AutoMapper+ suffice, or are Symfony-specific features (e.g., YAML config) critical?
  2. ORM Strategy:
    • How are Eloquent models mapped to DTOs? Would custom type converters be needed?
  3. Configuration Preference:
    • Does the team prefer PHP classes, YAML, or annotations for mappings?
  4. Performance Baseline:
    • What’s the current mapping overhead (e.g., manual array_map vs. Eloquent accessors)?
  5. Long-Term Flexibility:
    • Could this block future Laravel migrations (e.g., if switching to Symfony later)?
  6. Alternatives Evaluation:

Integration Approach

Stack Fit

  • Primary Fit:
    • Symfony/Laravel hybrid apps (e.g., using Symfony components like API Platform, Mercure, or UX).
    • Legacy Laravel apps with Symfony bundles already integrated.
  • Secondary Fit:
    • Laravel projects willing to accept Symfony dependencies for mapping complexity.
  • Non-Fit:
    • Vanilla Laravel apps without Symfony components.
    • Projects where simplicity (e.g., collect($model)->toArray()) is prioritized over mapping flexibility.

Migration Path

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.

Compatibility

  • Laravel: No official support—requires custom integration.
    • PHP 8.1+: Required by AutoMapper+.
    • Composer: composer require automapper/automapper-plus (standalone) or the bundle (Symfony path).
  • Eloquent:
    • Basic mappings (e.g., UserUserDTO) work out-of-the-box.
    • Complex relations (e.g., HasMany, MorphTo) need custom type converters.
  • Collections:
    • AutoMapper+ supports iterable mapping, but Laravel Collections may need adapters.
  • Caching:
    • AutoMapper+ caches compiled mappings; ensure OPcache is enabled for performance.

Sequencing

  1. Dependency Setup:
    • Choose standalone AutoMapper+ (Laravel) or bundle + Symfony components (hybrid).
  2. Configuration:
    • Start with PHP-based mappings (easiest for Laravel).
    • Example:
      use AutoMapperPlus\AutoMapper;
      use AutoMapperPlus\Configuration\Configuration;
      
      $mapper = AutoMapper::getInstance();
      $mapper->map()->entity(\App\Models\User::class, \App\DTO\UserDTO::class);
      
  3. Pilot Module:
    • Migrate one high-complexity module (e.g., OrderOrderDTO).
  4. Testing Framework:
    • Implement unit tests for mappings (e.g., assert OrderDTO properties).
  5. Gradual Replacement:
    • Replace manual mappings in API responses, services, and repositories.
  6. Optimization:
    • Profile mapping performance (e.g., bulk operations).
    • Adjust caching or type converters as needed.

Operational Impact

Maintenance

  • Pros:
    • Reduces boilerplate: Eliminates repetitive setName($model->name) code.
    • Centralized logic: Mappings defined in one place (e.g., app/Mappings/).
    • Type safety: Catches property mismatches at runtime (vs. manual errors).
  • Cons:
    • Configuration complexity: YAML/PHP mappings may become hard to debug.
    • Laravel-Symfony friction: Custom integration may drift from upstream updates.
    • Testing overhead: Requires additional test coverage for mappings.
  • Best Practices:
    • Document mappings with comments or READMEs.
    • Use feature flags for **
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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity