awd-studio/es-lib-maker-bundle
Installation:
composer require --dev awd-studio/es-lib-maker-bundle
Ensure config/bundles.php includes AwdEs\EsLibMakerBundle\EsLibMakerBundle::class under dev.
First Use Case: Generate a basic aggregate root:
php bin/console make:es:entity "YourNamespace\YourAggregate" -
This creates:
YourAggregate)WasCreated, WasChanged)Where to Look First:
php bin/console make:es:entity --help for options.src/YourNamespace/Domain/ for the new structure.awd-studio/es-lib-bundle is installed (required for runtime functionality).Aggregate Root Creation:
php bin/console make:es:entity "App\Order\Domain\OrderAggregate" --main-value-type="int" --main-value-name="orderId"
--main-value-type for custom value types (e.g., string, int, IDateTime).-- flags for defaults (e.g., string/value).Child Entity Workflow:
php bin/console make:es:entity "App\Order\Domain\Entity\OrderItem\OrderItem" "App\Order\Domain\OrderAggregate" --main-value-type="string" --main-value-name="sku"
"App\Order\Domain\OrderAggregate").Event-Driven Workflows:
WasCreated) in src/YourNamespace/Domain/Event/.apply() method:
public function apply(YourEvent $event): void {
// Handle event logic
}
Repository Integration:
YourAggregateRepositoryInterface) to define contracts.awd-studio/es-lib-bundle (e.g., EventSourcingRepository).Factory Pattern:
YourAggregateFactory) to create aggregates:
$factory = new YourAggregateFactory();
$aggregate = $factory->create($mainValue);
make:entity for non-ES entities, then manually integrate with ES Lib.DoctrineRepository from es-lib-bundle.$aggregate = (new YourAggregateFactory())->create('test-value');
$this->assertInstanceOf(YourAggregate::class, $aggregate);
Missing Dependencies:
Class 'AwdEs\EsLib\...' not found.awd-studio/es-lib-bundle:
composer require awd-studio/es-lib-bundle
Namespace Conflicts:
--machine-name) or manually adjust namespaces.Event Sourcing Runtime:
es-lib-bundle is configured in config/packages/es_lib.yaml:
es_lib:
event_store: doctrine # or 'doctrine', 'in-memory', etc.
Type Safety:
main-value-type (e.g., IDateTime) requires the awd-studio/es-lib package’s types.composer require awd-studio/es-lib
Generated Code Overrides:
--force to overwrite existing files (if supported in future versions).--no-interaction to avoid prompts.Event Application:
dd($event) in apply() to inspect event payloads during development.Custom Events:
src/YourNamespace/Domain/Event/ and reference them in apply():
public function apply(CustomEvent $event): void { ... }
Repository Extensions:
public function findByCriteria(Criteria $criteria): array { ... }
Factory Customization:
public function create(string $value): YourAggregate {
if (empty($value)) {
throw new \InvalidArgumentException('Value cannot be empty.');
}
return parent::create($value);
}
Machine Names:
--machine-name to enforce consistency in attributes (e.g., ORDER_ROOT for order_id).Dev vs. Prod:
dev only. Manually add it to bundles.php for production if needed (unlikely, as it’s a maker tool).PHP 8.3+ Features:
Symfony Maker Integration:
--dry-run to preview changes:
php bin/console make:es:entity "YourAggregate" -- --dry-run
How can I help you explore Laravel packages today?