Using Github Webhooks with PHP

Originally published at:

In the first part of our series, we talked about the Github API and built a demo in the process. In this part we are going to explore the Webhooks API, and we will build a demo to showcase the API usage. Let’s get started.

What We’re Building

In this article we are going to set up a demo that receives every push from Github and saves it to a database. We are also going to create a page to display the list of our repository committers ordered by the number of commits. You can check the final result on Github.

Setting Up the Environment

We will be using Laravel 5 as our framework, and because our application must be accessible from the internet to work with Github Webhooks, we can use Heroku to host our code. You can check this post to get started with Heroku.


Adding Mysql

After creating our app on Heroku, we need to add MySQL to store the received data.

heroku addons:add cleardb

You can go to your dashboard to get your database connection credentials. Set the necessary variables inside your config as you can see in the example below.

Continue reading this article on SitePoint

Nice Article! While this article saves the Web-Hook Requests to a DB, I’ve found little tools to actually deploy your code from Github or Gitlab to your server (expect for paid services) – so I created to handle Web-Hooks and call scripts to deploy on your own server…
Check it out and maybe even help develop it further:
(I’m not a PHP pro…)

Thanks, I will check it out.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.