1. Go to this page and download the library: Download gian-tiaga/spiral-outbox library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gian-tiaga / spiral-outbox example snippets
final class PublishStockJob extends JobHandler
{
public function invoke(
string $outboxDeliveryId,
OutboxMessageLoaderContract $outboxMessageLoader,
): void {
$event = $outboxMessageLoader->load(
outboxDeliveryId: $outboxDeliveryId,
expectedMessageClass: AvailableStockChangedEvent::class,
);
// Вызов прикладного сценария с данными $event.
}
}
final class PublishStockJob extends JobHandler
{
public function invoke(string $outboxDeliveryId, bool $outboxLastAttempt): void {}
}
final class SyncCardsJob extends JobHandler
{
public function invoke(
string $outboxDeliveryId,
string $outboxDispatchId,
OutboxAttemptContract $outboxAttempt,
): void {
foreach ($portions as $portion) {
if (!$outboxAttempt->isCurrent(
outboxDeliveryId: $outboxDeliveryId,
outboxDispatchId: $outboxDispatchId,
)) {
return;
}
// Работа над одной порцией.
}
}
}