- Can I use this bundle in Laravel even though it’s designed for Symfony?
- Yes, but with custom adaptations. The bundle’s core features like auto-imported Bounded Contexts and Messenger buses require Laravel-specific workarounds, such as replacing Symfony’s Messenger with Laravel Queues for commands and Livewire/Inertia for queries. Start with `spatie/laravel-package-tools` for modularity.
- How do I set up Command/Query buses in Laravel using this bundle?
- The bundle’s `command.bus` and `query.bus` won’t work natively in Laravel. You’ll need to create custom interfaces (e.g., `CommandBus` dispatching to queues) and a `QueryBus` using Livewire or Inertia. Symfony’s `#[AsCommandHandler]` can be replaced with Laravel service binding macros or `doctrine/annotations`.
- Will this bundle work with Laravel’s package structure (e.g., spatie/laravel-package-tools)?
- Partially. The bundle’s `DddKernel` auto-imports Bounded Contexts, but Laravel lacks native kernel extensions. Use `spatie/laravel-package-tools` for modularity and manually register contexts in your `AppServiceProvider` via a `registerBoundedContexts()` method. Avoid relying on auto-import for routes/services.
- Does this bundle support Laravel’s event system for Domain Events?
- Yes, but indirectly. The bundle’s `RecordEvents` maps to Laravel’s `DomainEvents` or `Observers`. Replace Symfony’s event dispatching with Laravel’s `event(new YourEvent())` or use packages like `spatie/laravel-event-sourcing` for DDD event handling. No direct integration exists, but the concept translates.
- How do I handle synchronous queries (like Symfony’s `ask()`) in Laravel?
- Laravel lacks a native synchronous query bus. Use Livewire or Inertia to fetch query results reactively, or implement a custom `QueryBus` that resolves queries directly in the HTTP layer. Avoid blocking requests with queues—use database reads or API calls instead for synchronous responses.
- Is this bundle compatible with Laravel 10+? What about older versions?
- The bundle is Symfony-focused, so Laravel compatibility is limited. Test thoroughly with Laravel 9/10, but expect issues with newer features like first-party queues or Livewire 3.0. The bundle’s low adoption (12 stars) suggests it’s not actively maintained for Laravel. Use at your own risk or fork it.
- Can I replace the Stimulus Autocomplete with Livewire or Alpine.js?
- Yes, but with tradeoffs. The bundle’s Stimulus/Tom Select integration can be swapped for Livewire’s autocomplete components or Alpine.js + Tom Select. Livewire offers real-time updates, while Alpine.js requires manual JavaScript. Multi-select and icons may need custom Tailwind CSS or Tom Select setup.
- What’s the performance impact of auto-importing Bounded Contexts in Laravel?
- Auto-importing contexts could slow boot time in Laravel, as the bundle scans directories for configs. Laravel’s package auto-discovery is lighter but lacks the bundle’s granularity. Test with `php artisan optimize` and monitor boot time. For large apps, manually register contexts to avoid overhead.
- Are there better Laravel alternatives for DDD with CQRS?
- Yes. Consider `spatie/laravel-ddd` for DDD fundamentals or `laravel-ide-helper` + custom interfaces for CQRS. For CQRS specifically, pair Laravel Queues with `spatie/laravel-activitylog` for event sourcing. These packages are Laravel-native, actively maintained, and avoid Symfony dependencies.
- How do I migrate from Symfony to Laravel while using this bundle?
- Start by replacing Symfony Messenger with Laravel Queues for commands and Livewire/Inertia for queries. Convert `#[AsCommandHandler]` to Laravel service bindings or annotations. Replace `DddKernel` with a custom `AppServiceProvider` for context registration. Test incrementally—expect breaking changes due to framework differences.