Skip to content

Instantly share code, notes, and snippets.

@dgafka
Last active September 24, 2022 08:31
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/5ac563eaa9305902b8ec8cc71ff7f0c4 to your computer and use it in GitHub Desktop.
Save dgafka/5ac563eaa9305902b8ec8cc71ff7f0c4 to your computer and use it in GitHub Desktop.
Working with asynchronous errors in PHP
<?php
#[AsMessageHandler]
class NotificationServiceHandler
{
public function __invoke(OrderWasPlaced $message)
{
// send an SMS message!
}
}
#[AsMessageHandler]
class PaymentServiceHandler
{
public function __invoke(OrderWasPlaced $message)
{
// take a payment from credit card
}
}
# In your symfon config, making handlers asynchronous
framework:
messenger:
routing:
# async is whatever name you gave your transport above
'OrderWasPlaced': async
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment