Aggregate
Info
You can find out more about aggregates in the library documentation. This documentation is limited to bundle integration.
Register aggregates
A path must be specified for Event Sourcing to know where to look for your aggregates.
Tip
You can also define multiple paths by specifying an array.
Define aggregates
Next, you need to create a class to serve as an aggregate.
In our example it is a hotel. This class must inherit from AggregateRoot
and get the Aggregate
attribute.
namespace App\Domain\Hotel;
use Patchlevel\EventSourcing\Aggregate\AggregateRoot;
use Patchlevel\EventSourcing\Attribute\Aggregate;
#[Aggregate(name: 'hotel')]
final class Hotel extends AggregateRoot
{
// ...
}
Note
You should read here how the aggregates then work internally.