Our package supports a simple command bus implementation that's able to automatically map commands to aggregate roots. If you want to use dedicated command objects, this can be a useful feature in order to prevent much boilerplate for writing command handlers. It's also possible to manually create command handlers if you want to.
A command looks like this:
#[AggregateUuid] public string $cartUuid,
public string $cartItemUuid,
public Product $product,
public int $amount,
The #[HandledBy] attribute takes any invokable class. If you use an aggregate root class, the #[AggregateUuid] property is also required in order to map a command to an aggregate root.
If a command is handled by an aggregate root, you can simply add a method on that aggregate root which takes the command as an argument, and the rest will be handled for you:
Also note that these commands can be mapped to aggregate partials, this is especially useful when you don't want to provide a manual mapping of public methods between the aggregate root and its partials.