Download the PHP package widop/github-hook-provider without Composer

On this page you can find all versions of the php package widop/github-hook-provider. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package github-hook-provider

README

Build Status

The library provides a Silex provider allowing you to execute your job on any Github WebHook.

Installation

The library is distributed through Composer. So, fist, install it :)

Create a composer.json file at the root directory of you project & put the following inside:

As the library provides optional debugging, you can enable it by installing & registering the build-in Silex MonologServiceProvider:

Then, install the libraries:

Create your application

Now, we have everything locally, we can create the Silex application. Usually, we follow the following structure:

The web/hook.php looks like:

In this structure, the web directory is the vhost root directory of our application & the hook.php script is the frontend controller managing our Github WebHook. So, if we create a vhost with my-domain.com as domain, we can put http://my-domain.com/hook.php as Github Webhook.

The src directory should not exist yet. You can create it, we will need it in the next steps :)

Register the provider

The Silex application (which do nothing...) is up :)

Now, we need to register & configure the Wid'op Github Hook provider which will allow us to play with Github hooks. For that, simply update the hook.php:

When you go to the Github WebHook configuration accessible in your Github repo setting, you have a list of IPs which can be trusted for Github WebHooks. The provider needs this list of IPs in order to secure the entry point. You can obviously provide an empty array but it is strongly not recommended!

Mount the controller

The Silex application with his provider is now well configured (but still do nothing...) :)

To finish the work, we need to mount the controller. One more time, update the hook.php:

You're done! The set up is finished.

What next?

Next? It can be interesting to write our custom stuffs which will be executed when a valid hook is received... :)

How does it work?

As Silex itself, the provider is builded around the event dispatcher. When a hook is received & has been validated against the IP firewall & the hook configuration, the github_hook event is fired & an event wrapping all informations about the hook are propagated to all listeners/subscribers. So, we just have to write our event listener/subscriber.

You can register as many listener/subscribers you want & archive more complex use cases by playing with priorities or event propagation...

Write the Hook Subscriber

We recommend you to put your code, in the src directory:

As we have added the Acme namespace, we need update the composer.json in order to autoload new classes:

Register the Hook Subscriber

Our hook subscriber is defined & it does our custom stuffs. Now, we need to register it on the event dispatcher. For that, we have two solutions: Directly in the hook.php or through a Silex provider.

Direct

Register our hook subscriber in the hook.php:

Silex Provider

Create our hook provider:

Then, register our hook provider in the hook.php:

Contribute

We love contributors! The library is open source, if you'd like to contribute, feel free to propose a PR!

License

The Wid'op Github Hook Silex Provider is under the MIT license. For the full copyright and license information, please read the LICENSE file that was distributed with this source code.


All versions of github-hook-provider with dependencies

PHP Build Version
Package Version
Requires silex/silex Version 1.0.*
symfony/config Version 2.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package widop/github-hook-provider contains the following files

Loading the files please wait ....