PHP code example of rasuvaeff / yii3-outbox-webhooks-bridge
1. Go to this page and download the library: Download rasuvaeff/yii3-outbox-webhooks-bridge 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/ */
rasuvaeff / yii3-outbox-webhooks-bridge example snippets
use Rasuvaeff\Yii3OutboxWebhooksBridge\ConfigWebhookEndpointProvider;
use Rasuvaeff\Yii3Webhooks\WebhookEndpoint;
$endpointProvider = new ConfigWebhookEndpointProvider(map: [
'order.created' => [
new WebhookEndpoint(url: 'https://partner-a.example.com/hooks', secret: 'secret-a'),
new WebhookEndpoint(url: 'https://partner-b.example.com/hooks', secret: 'secret-b'),
],
'order.paid' => [
new WebhookEndpoint(url: 'https://partner-a.example.com/hooks', secret: 'secret-a'),
],
]);
use Rasuvaeff\Yii3OutboxWebhooksBridge\OutboxWebhookPublisher;
$publisher = new OutboxWebhookPublisher(
dispatcher: $dispatcher, // your WebhookDispatcher impl
endpointProvider: $endpointProvider,
deliveryStorage: $deliveryStorage, // e.g. DbWebhookDeliveryStorage
);
use Rasuvaeff\Yii3Outbox\Processor;
$processor = new Processor(
storage: $outboxStorage,
publisher: $publisher,
clock: $clock,
);
// In a background worker or console command:
$result = $processor->process(types: ['order.created', 'order.paid']);
use Rasuvaeff\Yii3OutboxWebhooksBridge\WebhookEndpointProvider;
use Rasuvaeff\Yii3Webhooks\WebhookEndpoint;
final readonly class DbWebhookEndpointProvider implements WebhookEndpointProvider
{
public function __construct(private \PDO $db) {}
public function getEndpointsForType(string $type): array
{
// load from DB...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.