https://github.com/open-solid/domain-bundle
Symfony bundle for domain building blocks
https://github.com/open-solid/domain-bundle
ddd domain-events symfony-bundle
Last synced: about 1 year ago
JSON representation
Symfony bundle for domain building blocks
- Host: GitHub
- URL: https://github.com/open-solid/domain-bundle
- Owner: open-solid
- License: mit
- Created: 2024-04-30T05:16:49.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-13T21:23:55.000Z (over 1 year ago)
- Last Synced: 2025-03-24T17:21:17.685Z (about 1 year ago)
- Topics: ddd, domain-events, symfony-bundle
- Language: PHP
- Homepage:
- Size: 16.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Domain Bundle for Symfony framework
A Symfony bundle for domain building blocks (https://github.com/open-solid/domain).
## Installation
```console
$ composer require open-solid/domain-bundle
```
## Usage
```php
use OpenSolid\Domain\Event\Bus\EventBus;
use OpenSolid\Domain\Event\DomainEvent;
use OpenSolid\DomainBundle\Attribute\AsDomainEventSubscriber;
class UserRegistered extends DomainEvent
{
}
#[AsDomainEventSubscriber]
class UserRegisteredHandler
{
public function __invoke(UserRegistered $event): void
{
// Handle the event
}
}
class UserService
{
public function __construct(private EventBus $eventBus)
{
}
public function registerUser(): void
{
// Register the user
$this->eventBus->publish(new UserRegistered('uuid'));
}
}
```
## License
This software is published under the [MIT License](LICENSE)