An agnostic package that handles the registration and delivery of webhook notifications to external systems
Via Composer
$ composer require benrowe/webhooks
<?php
$webhookService = new \Benrowe\Webhooks\WebhookService();
$webhook = new \Benrowe\Webhooks\Webhook('http://localhost/path/to/call');
$webhook->listenTo(MyEvent::class);
$webhookService->subscribe($webhook);
// later
$webhookService->dispatchEvent(new MyEvent, $payload);
Please see CHANGELOG for more information what has changed recently.
$ composer test
Please see CONTRIBUTING and CONDUCT for details.
If you discover any security related issues, please email ben.rowe.83@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
// constructor
$service = new \Benrowe\Webhooks\WebhookService(StorageInterface $storage);
// primary methods
$service->subscribe(WebhookSubscription $subscription);
$service->unsubscribe(WebhookSubscription $subscription);
$service->dispatchEvent(WebhookEvent $event);
$service->dispatch(string $eventName);
// secondary methods
$service->protocols;//collection
$service->protocols->register(ProtocolHandlerInterface $handler);
Event {
Name string
}
WebhookSubscription {
PayloadUrl string
Conte
}
- Persistance of the registered webhooks is handled by the
StorageInterface
- Protocol handlers are registered against the service (http(s), amqp). Each protocol handler
- Content type handlers are registered against the service (json, yaml, xml, etc). When registering a new Subscription, it will verify the payload url to see if there's an appropriate handler registered.
- By default we will include a http(s) handler