Skip to content

Instantly share code, notes, and snippets.

@dgafka
Created September 30, 2022 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgafka/9c2959029bca829991d03c034d841bf9 to your computer and use it in GitHub Desktop.
Save dgafka/9c2959029bca829991d03c034d841bf9 to your computer and use it in GitHub Desktop.
loosely-coupled-microservices-06.php
<?php
class OrderService
{
#[EventHandler]
public function placeOrder(OrderWasPlaced $event, DistributedBus $distributedBus, DomainService $domainService): void
{
$distributedBus->convertAndPublishEvent("order.was_placed",
[
"orderId" => $event->orderId()
],
[
"currentDomain" => $domainService->getDomain()
]
);
}
}
class AuditLogService
{
#[Distributed]
#[EventHandler("order.was_placed")]
public function store(string $event, #[Header("currentDomain")] string $domain): void
{
// store order along with domain
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment