pccomponentes/ddd
Mini framework PHP para construir aplicaciones con DDD + CQRS + Event Sourcing, orientado a la escritura. Propone arquitectura hexagonal (Application/Domain/Infrastructure/EntryPoint/Util) y guía de capas, dependencias y persistencia basada en eventos.
The pccomponentes/ddd package enforces a strict hexagonal architecture with DDD/CQRS/ES, which aligns well with Laravel applications requiring domain isolation, event-driven workflows, or scalable read/write separation. Key strengths for Laravel integration:
Domain layer’s agnosticism to Laravel’s Eloquent/Query Builder enables clean separation of business logic, reducing coupling to framework-specific implementations.Illuminate\Events\Dispatcher) can integrate with the package’s event-driven domain models, though additional infrastructure (e.g., message queues) is needed for async CQRS.Uuid, DateTimeValueObject) complement Laravel’s native types (e.g., Carbon, Str::uuid()) while adding DDD-specific constraints (e.g., UTC enforcement, v7 UUIDs).EntryPoint layer, though manual wiring may be required for non-standard dependencies (e.g., MongoDB repositories).Misalignment Risks:
Application, Infrastructure) may conflict with Laravel’s monolithic app/ structure. Requires disciplined project organization.Model::create() with event appenders).Domain layer (e.g., replace Eloquent models with DDD entities), then extend to Application/Infrastructure.EntryPoint can wrap Laravel’s HTTP controllers (e.g., Route::post('/orders', OrderController::class)) via dependency injection.Application layer but may need adjustments for domain-specific assertions.Str::uuid() can be replaced with Uuid::create() (v7) or Uuid::v4() for backward compatibility.Order) to use DDD entities/VOs, keeping Laravel’s Eloquent for persistence.events table.EventSourcingServiceProvider for event storage).EntryPoint layer can integrate with Laravel’s container via bindings (e.g., bind('App\Domain\Repository\OrderRepository', fn() => new MongoOrderRepository())).Application layer handlers (e.g., public function store(OrderCreateRequest $request, OrderCreateHandler $handler)).event(new OrderCreated($orderId))), which the package’s infrastructure can consume.EventStoreRepository) that append to an events table with columns: aggregate_id, event_type, payload, occurred_at.queue:work) to process events and update read models. For advanced use, integrate RabbitMQ via libraries like php-amqplib.Domain layer and test Application handlers with Laravel’s Mockery.EntryPoint behavior (e.g., API responses).User) to use the package’s VOs (e.g., Uuid, EmailValueObject) and entities.
UserEntity with UserId, UserEmail VOs).events table and a custom repository.
How can I help you explore Laravel packages today?