PHP code example of kurozumi / github-webhook-bundle
1. Go to this page and download the library: Download kurozumi/github-webhook-bundle 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/ */
kurozumi / github-webhook-bundle example snippets
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());
}
}
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
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.