awd-studio/es-lib-maker-bundle
A Symfony bundle providing maker commands for seamless integration with Event Sourcing patterns. Features code generation tools for event-sourced aggregates, value objects, and domain events following Domain-Driven Design principles.
ES Lib Maker Bundle is part of the ES Lib ecosystem, designed to simplify the implementation of Event Sourcing in Symfony applications. This bundle provides maker commands that generate boilerplate code for event-sourced entities, following best practices and patterns.
composer require --dev awd-studio/es-lib-maker-bundle
The bundle will be automatically registered in your config/bundles.php for the dev environment.
If the bundle is not registered automatically, you can register it manually by adding the following line to your config/bundles.php file:
return [
// ...
AwdEs\EsLibMakerBundle\EsLibMakerBundle::class => ['dev' => true],
];
The bundle provides a maker command to generate event-sourced entities:
# Create an aggregate root
php bin/console make:es:entity "YourNamespace\YourAggregate" -
# Create a child entity
php bin/console make:es:entity "YourNamespace\YourAggregate\ChildEntity" "App\YourNamespace\Domain\YourAggregate"
entity-name: The fully qualified class name for the entity (e.g., Foo\FooAggregate)aggregate-root: The root for the aggregate (use - to configure the aggregate root itself)--machine-name: A unique name for the entity (e.g., FOO_AGGREGATE)--main-value-type: The type for the main value (default: string)--main-value-name: The name for the main value (default: value)For each entity, the bundle generates:
WasCreated: Event for entity creationWasChanged: Event for entity changesWasActivated/WasDeactivated: Events for entity activation/deactivation (for simple entities)NotFound: Exception for when an entity is not foundPersistenceError: Exception for persistence errorsphp bin/console make:es:entity "Product\ProductAggregate" - --main-value-type="string" --main-value-name="name"
This will generate:
App\Product\Domain\ProductAggregate - The aggregate root classphp bin/console make:es:entity "Order\OrderAggregate" - --main-value-type="int" --main-value-name="orderNumber" --machine-name="CUSTOMER_ORDER"
This will generate:
App\Order\Domain\OrderAggregate - The aggregate root class with an integer main valuephp bin/console make:es:entity "Appointment\AppointmentAggregate" - --main-value-type="IDateTime" --main-value-name="scheduledAt"
This will generate:
App\Appointment\Domain\AppointmentAggregate - The aggregate root class with a DateTime main valuephp bin/console make:es:entity "Product\ProductAggregate\ProductVariant" "App\Product\Domain\ProductAggregate" --main-value-type="string" --main-value-name="sku"
This will generate:
App\Product\Domain\Entity\ProductVariant\ProductVariant - The child entity classphp bin/console make:es:entity "User\UserAggregate\UserPreference" "App\User\Domain\UserAggregate" --main-value-type="bool" --main-value-name="isEnabled"
This will generate:
App\User\Domain\Entity\UserPreference\UserPreference - A simple child entity with boolean statephp bin/console make:es:entity "Order\OrderAggregate\OrderItem\ItemDiscount" "App\Order\Domain\OrderAggregate" --main-value-type="float" --main-value-name="amount" --machine-name="ORDER_ITEM_DISCOUNT"
This will generate:
App\Order\Domain\Entity\OrderItem\ItemDiscount\ItemDiscount - A nested child entityThe ES Lib ecosystem includes the following projects:
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
How can I help you explore Laravel packages today?