- Can I use this package in a Laravel project without Symfony’s full framework?
- Yes, this package is designed for Laravel-first adoption. It leverages Symfony’s DDD components (like SimpleBus and Doctrine) but integrates cleanly with Laravel’s service container, Artisan, and Eloquent. You only need Doctrine ORM (via fruitcake/laravel-doctrine) and minimal Symfony DI setup.
- How do I set up event sourcing in Laravel with this package?
- Run `composer require becklyn/ddd-symfony-bridge` and `php artisan doctrine:migrations:migrate` to create the event store tables. Configure `services.yaml` with the `symfony_property_normalizer` and `symfony_enum_normalizer` for proper serialization. Your aggregate roots will automatically persist events to the store.
- Will this work with Laravel’s native Eloquent models?
- No, this package is optimized for Doctrine ORM (via `becklyn/ddd-doctrine-bridge`). If you need both, use Doctrine for aggregates/events and Eloquent for read models, but avoid mixing them in the same bounded context to prevent conflicts.
- How do I register command handlers and event subscribers in Laravel?
- Add the `event_subscribers` and `command_handlers` configurations to `services.yaml` to auto-discover classes ending in `Subscriber` or `Handler`. Laravel’s autowiring will handle the rest, mirroring Symfony’s tag-based registration.
- Does this package support Laravel’s latest versions (e.g., 10.x)?
- The package targets Symfony’s ecosystem, which may lag behind Laravel’s rapid releases. Test thoroughly in a staging environment, especially for Doctrine migrations and DI conflicts. Check the [GitHub issues](https://github.com/Becklyn/ddd-symfony-bridge/issues) for version-specific notes.
- Can I use this for CQRS without event sourcing?
- Yes, disable the event store via `use_event_store: false` in your config. The package still provides SimpleBus for command handlers and event subscribers, allowing you to separate read/write models while using Laravel’s native database for queries.
- What’s the performance impact of SimpleBus in Laravel?
- SimpleBus is synchronous by default, which may introduce latency for high-throughput APIs. For async processing, integrate Symfony’s `Messenger` component or use Laravel’s queues to offload event publishing. Benchmark under your expected load.
- Are there alternatives to this package for Laravel DDD?
- Yes, consider `spatie/laravel-event-sourcing` for simpler event sourcing or `asgr/ddd` for a Laravel-native DDD framework. However, this package uniquely combines Symfony’s mature DDD tooling with Laravel’s ecosystem, offering more advanced features like aggregate invariants and CQRS.
- How do I handle enums in events when Laravel and Symfony have different serializers?
- Override Symfony’s `BackedEnumNormalizer` in `services.yaml` to ensure compatibility with Laravel’s enum handling. If conflicts persist, create a custom normalizer that aligns with your project’s enum strategy (e.g., using PHP 8.1’s native enums).
- Can I use this package in a microservice architecture with Laravel?
- Absolutely. The package’s focus on bounded contexts and event-driven architecture makes it ideal for microservices. Deploy each service with its own Doctrine event store, and use SimpleBus for cross-service communication via events or commands.