Download the PHP package loilo/github-webhook-handler without Composer
On this page you can find all versions of the php package loilo/github-webhook-handler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download loilo/github-webhook-handler
More information about loilo/github-webhook-handler
Files in loilo/github-webhook-handler
Package github-webhook-handler
Short Description Validate and utilize GitHub webhooks
License MIT
Informations about the package github-webhook-handler
# GitHub Webhook Handler
Handle GitHub webhooks with PHP.
Installation
Usage
Start by creating a handler:
$secret is the webhook secret defined in the GitHub backend. It can be omitted, however providing it is strongly recommended to prevent abuse of the endpoint.
To handle a request (specifically, a PSR-7 ServerRequestInterface), pass that request to the handle method:
If the webhook request is invalid, Delivery object which provides access to the event that caused the hook request and to the payload data that was sent along with it:
Single-File Endpoint
There may be very simple cases where you're not using a PHP framework for your script and just want to put a single PHP file endpoint out there. To avoid having to deal with exceptions and creating appropriate error responses, you may use the respond() method:
Now you can safely use the $delivery object without any further worries — if validation of the webhook request fails, the handler will set an appropriate HTTP status code, print the error message and stop script execution.
Pro Tip: Not having a PSR-7 request object at hand? Install the
guzzlehttp/psr7package and use\GuzzleHttp\Psr7\ServerRequest::fromGlobals()to create a request object from the environment.
All versions of github-webhook-handler with dependencies
ext-hash Version *
ext-json Version *
psr/http-message Version ^1.0