PHPackages                             awd-studio/es-lib-maker-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. awd-studio/es-lib-maker-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

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 DDD principles.

v0.0.0.12-alpha(10mo ago)013MITPHPPHP &gt;=8.3

Since Jun 30Pushed 10mo agoCompare

[ Source](https://github.com/awd-studio/es-lib-maker-bundle)[ Packagist](https://packagist.org/packages/awd-studio/es-lib-maker-bundle)[ Docs](https://github.com/awd-studio/es-lib-maker-bundle)[ RSS](/packages/awd-studio-es-lib-maker-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (9)Versions (13)Used By (0)

ES Lib Maker Bundle
===================

[](#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.

[![MIT License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](https://choosealicense.com/licenses/mit/)[![PHP Version](https://camo.githubusercontent.com/c8d8dad6beb757a2b8acba331d16140813699543b88a37af0a81f20bd35f61de/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d626c7565)](https://www.php.net/)[![Symfony Version](https://camo.githubusercontent.com/ad49a9338a28f510de86f3ebea305fb0e7c0dd144cf3b48a72714e9a815426ec/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d372e302532422d626c61636b)](https://symfony.com/)

Overview
--------

[](#overview)

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.

Installation
------------

[](#installation)

### Prerequisites

[](#prerequisites)

- PHP 8.3 or higher
- Symfony 7.0 or higher
- Composer

### Steps

[](#steps)

1. Require the bundle via Composer as a dev dependency:

```
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],
];
```

Usage
-----

[](#usage)

### Creating an Event-Sourced Entity

[](#creating-an-event-sourced-entity)

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"
```

#### Command Options

[](#command-options)

- `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`)

### Generated Code Structure

[](#generated-code-structure)

For each entity, the bundle generates:

1. **Entity Class**: The main entity class with event handlers
2. **Events**:
    - `WasCreated`: Event for entity creation
    - `WasChanged`: Event for entity changes
    - `WasActivated`/`WasDeactivated`: Events for entity activation/deactivation (for simple entities)
3. **Repository**:
    - Interface
    - Implementation
4. **Factory**:
    - Interface
    - Implementation
5. **Exceptions**:
    - `NotFound`: Exception for when an entity is not found
    - `PersistenceError`: Exception for persistence errors

Examples
--------

[](#examples)

### Creating an Aggregate Root

[](#creating-an-aggregate-root)

#### Basic String-Based Aggregate

[](#basic-string-based-aggregate)

```
php 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 class
- Events, repository, factory, and exceptions for the aggregate

#### Integer-Based Aggregate with Custom Machine Name

[](#integer-based-aggregate-with-custom-machine-name)

```
php 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 value
- Events, repository, factory, and exceptions for the aggregate
- The machine name "CUSTOMER\_ORDER\_ROOT" will be used in the entity attributes

#### DateTime-Based Aggregate

[](#datetime-based-aggregate)

```
php 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 value
- Special comparison logic for DateTime objects in the change method

### Creating Child Entities

[](#creating-child-entities)

#### Basic String-Based Child Entity

[](#basic-string-based-child-entity)

```
php 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 class
- Events, repository, factory, and exceptions for the child entity

#### Boolean-Based Child Entity (Simple Entity)

[](#boolean-based-child-entity-simple-entity)

```
php 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 state
- Activation/deactivation events and methods

#### Nested Child Entity with Custom Machine Name

[](#nested-child-entity-with-custom-machine-name)

```
php 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 entity
- The machine name "ORDER\_ITEM\_DISCOUNT" will be used in the entity attributes

Related Projects
----------------

[](#related-projects)

The ES Lib ecosystem includes the following projects:

- [ES Lib](https://github.com/awd-studio/es-lib): Core library for Event Sourcing
- [ES Lib Bundle](https://github.com/awd-studio/es-lib-bundle): Symfony bundle for the ES Lib library
- [ES Lib Maker Bundle](https://github.com/awd-studio/es-lib-maker-bundle): This project, providing maker commands for Event Sourcing entities

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

This project is licensed under the MIT License - see the LICENSE file for details.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance54

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

12

Last Release

320d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/15061745?v=4)[Anton Karpov](/maintainers/awd-studio)[@awd-studio](https://github.com/awd-studio)

---

Top Contributors

[![awd-studio](https://avatars.githubusercontent.com/u/15061745?v=4)](https://github.com/awd-studio "awd-studio (14 commits)")

---

Tags

phplibrarycode generatorDomain Driven Designdddevent sourcingessymfony-maker

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/awd-studio-es-lib-maker-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/awd-studio-es-lib-maker-bundle/health.svg)](https://phpackages.com/packages/awd-studio-es-lib-maker-bundle)
```

###  Alternatives

[nwidart/laravel-broadway

A Laravel adapter for the Broadway ES/CQRS package.

12315.0k](/packages/nwidart-laravel-broadway)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
