Skip to content

Instantly share code, notes, and snippets.

@dgafka
Created March 11, 2022 17:00
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/ff76d31c93368800325404424538fb66 to your computer and use it in GitHub Desktop.
Save dgafka/ff76d31c93368800325404424538fb66 to your computer and use it in GitHub Desktop.
scheduling-in-php-02.php
<?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