Download the PHP package katmore/webhook without Composer
On this page you can find all versions of the php package katmore/webhook. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download katmore/webhook
More information about katmore/webhook
Files in katmore/webhook
Package webhook
Short Description Wrappers and webservice to handle GitHub Webhook requests.
License MIT GPL-3.0+
Homepage https://github.com/katmore/webhook
Informations about the package webhook
Webhook
Github Webhook client receiver wrappers and webservice.
Description
The Webhook Project facilitates workflow integration of Github Webhook requests. It provides end-point installer script for a self-contained solution that is easy to deploy.
Requirements
- PHP 7.2 or higher
Usage
End-point Installer Script
The command-line script bin/add-endpoint.php creates a webservice end-point that responds to a Github Webhook for the PushEvent on a remote repository by updating a local repository and to a PingEvent by displaying a success message.
The simplest way to prepare the end-point installer is to copy this project somewhere and run Composer:
The installer can be invoked without any arguments; it will prompt for all the required parameters (such as the remote URL, local repo path, webhook secret, etc.):
The --help
switch will provide details on more advanced usage (such as quiet and non-interactive modes).
Wrapper Classes
To use this project's wrapper classes within your existing project, the main topics of focus will be the Webhook\Request class and Payload objects. As a recomended first step, add a dependancy using Composer to your existing project:
The Webhook\Request class facilitates interpreting the message body and related HTTP headers of a Github Webhook request. The Webhook\Request class constructor will instantiate and populate a PushEvent Webhook request.
The Payload object as populated by the Webhook\Request constructor is available using the Webhook\Request::getPayload() method as detailed in the example below:
Validating a request's "Hub Signature"
At some point in the handling of a Webhook request it is critical that the "Hub Signature" be validated against the shared "Secret" for obvious security reasons. The Webhook\Request class.
Using the provided end-point example
An end-point example is provided at web/endpoint-example.php which responds to a PushEvent by invoking a 'git pull' or any custom code placed in a callback function, as configured. It also responds to a a PingEvent with a success message.
-
copy the provided web/endpoint-example.php...
-
edit to specify configuration...
-
change the value of
$config['RepoUrl']
to your GitHub repository URL: -
change the value of
$config['Secret']
to the "Secret" configured in Github for the webhook: -
leave the value of
$config['RepoPath']
empty to skip the repo update, or change it to the local system path of a repository to perform agit update
on every 'push' Webhook event: - place any custom code within the
onPushEvent
function that should be executed on every 'push' Webhook event
-
Unit Tests
coverage.txt
: unit test coverage reportphpunit.xml
: PHPUnit configuration filetests/phpunit
: source code for unit tests
To perform unit tests, execute phpunit located in the vendor/bin
directory.
The tests.sh
wrapper script is provided for convenience.
Legal
"Webhook" is distributed under the terms of the GPLv3 license.
Copyright (c) 2016-2018, Doug Bird. All rights reserved.
All versions of webhook with dependencies
ext-hash Version *
ext-json Version *