- Can I use this bundle directly in a Laravel project without Symfony?
- No, this bundle is designed for Symfony and requires Symfony’s dependency injection, configuration system, and event dispatcher. For Laravel, you’d need to either use standalone AutoMapper+ (automapper/automapper-plus) or build a custom bridge to integrate it with Laravel’s service container. The bundle won’t work out-of-the-box in vanilla Laravel.
- What Laravel versions does this bundle support?
- This bundle doesn’t natively support Laravel—it’s built for Symfony 3.4 through 8.x. However, if you’re using Laravel with Symfony components (like API Platform), you might integrate it indirectly. For pure Laravel, check standalone AutoMapper+ compatibility or Laravel-specific alternatives like spatie/laravel-data.
- How do I configure mappings in Laravel if I use this bundle?
- You’d configure mappings via PHP classes implementing `AutoMapperConfiguratorInterface`, similar to Symfony. However, Laravel’s PHP-first config (e.g., `config/mappings.php`) won’t work directly. You’d need to adapt Symfony’s YAML/XML/annotation styles to Laravel’s service providers or manually register configurators in `AppServiceProvider`.
- Does this bundle support Eloquent models for mapping?
- No, this bundle is optimized for Doctrine ORM. For Eloquent, you’d need to create custom type converters to handle relationships (e.g., `HasMany`), collections, or Laravel-specific accessors. Standalone AutoMapper+ might offer more flexibility here, but you’d still need to write adapters.
- What’s the performance impact of using AutoMapper+ in Laravel?
- AutoMapper+ uses reflection for mapping, which can introduce overhead in high-throughput Laravel routes. Benchmark against native Laravel solutions like `collect($model)->toArray()` or manual mapping (e.g., `Model::resource()`). For complex DTOs, the tradeoff may be worth it, but simple mappings might not justify the dependency.
- Are there Laravel-specific alternatives to this bundle?
- Yes. For DTOs with validation, consider `spatie/laravel-data`. For simple mappings, Laravel’s built-in `collect()` or manual array casting (e.g., `$model->toArray()`) often suffice. If you need advanced transformations, standalone AutoMapper+ (without the Symfony bundle) might integrate better with Laravel’s ecosystem.
- How do I test AutoMapper+ mappings in Laravel’s PHPUnit/Pest?
- AutoMapper+ includes test utilities, but they’re Symfony-focused. In Laravel, you’d need to mock the `AutoMapperInterface` or create Laravel-specific test helpers. Standalone AutoMapper+ might be easier to test since it doesn’t rely on Symfony’s testing tools. Use Laravel’s `Mockery` or `Pest` for dependency isolation.
- Can I use this bundle in production with Laravel?
- Only if your Laravel app already uses Symfony components (e.g., API Platform, Symfony UX). Otherwise, the bundle adds unnecessary complexity and Symfony dependencies. For production, weigh the benefits against alternatives like `spatie/laravel-data` or native Laravel collections, which are more lightweight and maintainable.
- What’s the best way to integrate this bundle into a Laravel app?
- If you’re using Symfony components, register the bundle in your Symfony kernel (e.g., for API Platform). For Laravel, wrap AutoMapper+ in a Laravel service provider to handle dependency injection and configuration. Avoid mixing Symfony’s `services.yaml` with Laravel’s `config/services.php`—keep them separate to minimize conflicts.
- Will this bundle block future Laravel migrations or Symfony adoption?
- Yes, if your Laravel app isn’t already using Symfony components. The bundle locks you into Symfony’s DI and config systems, which may complicate future migrations to pure Laravel or Symfony. Standalone AutoMapper+ is more portable, while Laravel-native solutions (like `spatie/laravel-data`) avoid this risk entirely.