Skip to content

Instantly share code, notes, and snippets.

@dgafka
Last active January 1, 2023 18:26
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/15493c408991be810b63be601a792a2b to your computer and use it in GitHub Desktop.
Save dgafka/15493c408991be810b63be601a792a2b to your computer and use it in GitHub Desktop.
outbox-pattern-01.php
<?php
final class OrderService
{
#[CommandHandler]
public static function placeOrder(PlaceOrder $command, OrderRepository $orderRepository, EventBus $eventBus): self
{
$order = new Order($command->getOrderId(), $command->getProductName());
$orderRepository->save($order);
$eventBus->publish(new OrderWasPlaced($command->getOrderId(), $command->getProductName()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment