Installation
composer require aulasoftwarelibre/ddd-dev
Ensure your project meets the PHP 7.2+ and ext-mbstring requirements.
First Use Case
use AulaSoftwareLibre\DDDDev\EventSourcing\EventStore;
$eventStore = new EventStore(); // Configure with your storage (e.g., Doctrine, MongoDB)
php bin/console make:ddd:entity User
Key Entry Points
src/Domain/: Organize your domain models here.config/ddd.php: Check for package-specific configurations (if any; may need manual setup).Event-Driven Domain Modeling
AulaSoftwareLibre\DDDDev\Domain\AggregateRoot for event-sourced entities.
class Order extends AggregateRoot
{
public function place(): void
{
$this->recordThat(new OrderPlaced($this->id, $this->customerId));
}
}
EventStore to persist and replay events.
$eventStore->load($aggregateId)->when([
OrderPlaced::class => fn(OrderPlaced $event) => $this->handleOrderPlaced($event),
]);
Symfony Maker Integration
templates/ddd/ to fit your DDD conventions.
Example: Add #[UniqueEntity] annotations to generated entities.# Generate a Value Object
php bin/console make:ddd:value-object Email
# Generate an Aggregate Root
php bin/console make:ddd:aggregate Order
Dependency Injection
EventStore as a service in config/services.yaml:
services:
AulaSoftwareLibre\DDDDev\EventSourcing\EventStore: ~
public function __construct(private EventStore $eventStore) {}
prooph/event-store-doctrine for persistence.AulaSoftwareLibre\DDDDev\Testing\TestAggregateRoot for unit tests:
$aggregate = new TestAggregateRoot(Order::class);
$aggregate->record(new OrderPlaced(...));
$aggregate->assertRecordedThat(OrderPlaced::class);
No Official Documentation
README with usage examples. Rely on Prooph’s Event Sourcing docs for event-store patterns.tests/ directory for usage patterns.Symfony Maker Bundle Quirks
templates/ddd/ directory is auto-discovered by Symfony Maker.
Add to config/packages/maker.yaml:
maker:
namespace: '%kernel.project_dir%/templates'
symfony/maker-bundle), prioritize this package’s commands by adjusting the maker.yaml order.Event Store Configuration
EventStore manually. For Doctrine:
$eventStore = new EventStore(
new DoctrineEventStore(),
new DoctrineEventRepository()
);
DATABASE_URL).Event Replay Issues
$eventStore->setDebug(true);
Maker Command Errors
php bin/console cache:clear
Custom Value Objects
AulaSoftwareLibre\DDDDev\Domain\ValueObject for shared logic:
class Money extends ValueObject
{
public static function fromFloat(float $amount): self { ... }
}
Domain Events
DomainEvent interface for consistency:
interface DomainEvent extends \Prooph\EventSourcing\DomainEvent {}
Testing Utilities
TestAggregateRoot for custom assertions:
class CustomTestAggregateRoot extends TestAggregateRoot
{
public function assertOrderPlaced(): void { ... }
}
How can I help you explore Laravel packages today?