PHP code example of open-solid / domain-bundle
1. Go to this page and download the library: Download open-solid/domain-bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
open-solid / domain-bundle example snippets
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'));
}
}