alexandrebulete/ddd-symfony-bundle
DddKernel) directly supports modular Symfony architectures, enabling context isolation without manual config/ merges. This aligns with Laravel’s package-based modularity (e.g., spatie/laravel-package-tools) but requires custom adaptation in Laravel.CommandBus/QueryBus pattern (via Symfony Messenger) is a strong fit for Laravel projects using Queues for commands and Livewire/Inertia for queries. However, Laravel lacks native bus separation, necessitating custom interfaces or queue channel differentiation.#[AsCommandHandler]) mirrors Laravel’s service binding but would require custom annotations or macros (e.g., app()->bindWhen()).CommandBus interface dispatching to queues, QueryBus using Livewire).RecordEvents maps to Laravel’s Domain Events or Observers.Kernel lacks auto-import functionality; manual setup is error-prone.ask() (synchronous queries) would need Livewire/Inertia workarounds in Laravel.ask())?spatie/laravel-ddd) with higher adoption?| Feature | Symfony Fit | Laravel Adaptation |
|---|---|---|
| Bounded Contexts | DddKernel auto-imports BC configs |
Use spatie/laravel-package-tools + custom registerBoundedContexts() in AppServiceProvider |
| Command/Query Bus | Symfony Messenger (native) | Custom CommandBus (queues) + QueryBus (Livewire/Inertia) |
| Handler Registration | #[AsCommandHandler] attributes |
Laravel Macros or doctrine/annotations + custom service binding |
| Routing | Kernel auto-loads BC routes | Manual route grouping or RouteServiceProvider extensions |
| Autocomplete UI | Stimulus/Tom Select | Livewire + Tom Select or Alpine.js + Tailwind CSS |
| Event Handling | RecordEvents integration |
Laravel Domain Events or Observers |
| Configuration | config/packages/*.yaml |
config/ddd.php + custom Service Provider |
composer require alexandrebulete/ddd-symfony-bundle
DddKernel in src/Kernel.php.src/*/Infrastructure/Symfony/config/.#[AsCommandHandler]/#[AsQueryHandler] for auto-registration.messenger.yaml for middleware (e.g., transactions).AutocompleteType in forms.CommandBus/QueryBus interfaces.$commandBus->dispatch(new CreatePostCommand(...));
// Maps to: CreatePostCommand::dispatch();
$posts = $queryBus->ask(new GetPostsQuery());
// Maps to: Livewire component fetching via HTTP.
spatie/laravel-package-tools for BC packages.register() in AppServiceProvider to auto-load BC services:
$this->app->registerPath(__DIR__.'/../src/*/Infrastructure/Laravel');
RouteServiceProvider:
Route::prefix('posts')->group(function () {
Route::get('/', [PostController::class, 'index']);
});
// Livewire component for autocomplete
public function getUsers(): array { ... }
RecordEvents with Laravel’s Domain Events:
event(new PostCreated($post));
CommandBus/QueryBus in tests.DddKernel, migrate BC configs.#[AsCommandHandler] for auto-registration.CommandBus/QueryBus interfaces.spatie/laravel-package-tools).How can I help you explore Laravel packages today?