kurozumi/github-webhook-bundle

Maintainers

👁 kurozumi

Package info

github.com/kurozumi/github-webhook-bundle

Type:symfony-bundle

pkg:composer/kurozumi/github-webhook-bundle

Statistics

Installs: 94

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.2 2024-10-09 01:27 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 09e2c638c3e741f6b397e7bae6bb405e3af2e8d3

  • kurozumi <info.woop@a-zumi.net>

This package is auto-updated.

Last update: 2026-06-09 05:21:21 UTC


README

Installation

composer require kurozumi/github-webhook-bundle

The configuration:

# .env

WEBHOOK_GITHUB_SECRET=1z9Y48dbgqxZi...

Webhook

Create a route:

framework:
 webhook:
 routing:
 github:
 service: webhook.request_parser.github
 secret: '%env(WEBHOOK_GITHUB_SECRET)%'

And a consume:

use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\RemoteEvent\Attribute\AsRemoteEventConsumer;
use Symfony\Component\RemoteEvent\Consumer\ConsumerInterface;
use Symfony\Component\RemoteEvent\RemoteEvent;

#[AsRemoteEventConsumer(name: 'github')]
final class GithubConsumer implements ConsumerInterface
{
 public function __construct(
 private EventDispatcherInterface $eventDispatcher,
 ) {
 }

 public function consume(RemoteEvent $event): void
 {
 $this->eventDispatcher->dispatch($event, $event->getName());
 }
}

How to use

use Symfony\Component\EventDispatcher\EventSubscriberInterface
use Symfony\Component\RemoteEvent\RemoteEvent;

class GithubWebhookListener implements EventSubscriberInterface
{
 public static function getSubscribedEvents(): array
 {
 return [
 'pull_request' => 'onPullRequest',
 ]
 }
 
 public function onPullRequest(RemoteEvent $event): void
 {
 $payload = $event->getPayload();
 
 // do something
 }
}

Webhook events and payloads

https://docs.github.com/en/webhooks/webhook-events-and-payloads