Last active
September 24, 2022 08:31
-
-
Save dgafka/5ac563eaa9305902b8ec8cc71ff7f0c4 to your computer and use it in GitHub Desktop.
Working with asynchronous errors in PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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