First version of GitHub Webhook handler public on GitHub

Yesterday, I wrote about my efforts for creating an easy-to-use GitHub Webhooks handler in PHP, suitable for shared hosting environments.

After a few hours of making the code a little prettier, it is now public on GitHub. I remade the whole thing into an API style that I would enjoy using. Now, you can hook yourself up to GitHub Webhooks like this:

<?php
require_once "mt-github-webhook.php";

// Changes in the QA branch are pushed to the secret password-protected QA web site
\MT\GitHub\Webhook::onPushToBranch("qa-testing")->
                    forChangesInFolder("main-web-site/public_html")->
                    setGitHubCredentials("github-username", "My5ecretP@ssw0rd")->
                    pushChangesToFolder("/www/sites/qa.domain.com/public_html");

// Changes in the PRODUCTION branch are pushed to the public-facing web site
\MT\GitHub\Webhook::onPushToBranch("production")->
                    forChangesInFolder("main-web-site/public_html")->
                    setGitHubCredentials("github-username", "My5ecretP@ssw0rd")->
                    pushChangesToFolder("/www/sites/www.domain.com/public_html");
?>

The clone url is: https://github.com/lbrtw/mt-github-webhook.git. Feel free to fork and play around with it.

Posted by Anders Tornblad on Category PHP Labels
Tweet this