Created
March 11, 2022 17:00
-
-
Save dgafka/ff76d31c93368800325404424538fb66 to your computer and use it in GitHub Desktop.
scheduling-in-php-02.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 | |
class InvoiceService | |
{ | |
#[Scheduled("generateInvoices", endpointId: "invoiceGenerator")] | |
#[Poller(cron: "* * * * *")] | |
public function fetchUsersToInvoice(): array | |
{ | |
// fetch from database | |
return [100, 200]; | |
} | |
#[CommandHandler("generateInvoices")] | |
public function generateInvoicesFor(array $userIds): void | |
{ | |
foreach ($userIds as $userId) { | |
echo sprintf("Invoice generated for %s\n", $userId); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment