A complete PHP library for GitHub API v3

This is a simple Object Oriented wrapper for GitHub API v3, written with PHP7.

GitHub is a popular web-based Git repository hosting service, which offers all of the distributed revision control and source code management functionality of Git as well as adding its own features.

Since may 2013, GitHub announced Octokit, a new lineup of GitHub-maintained client libraries for the GitHub API. This means Octokit provide officially 3 libraries written in Ruby, Objective-C and .NET.

However, third-party libraries are available in other languages and particularly in PHP. At this time you can find at least 9 libraries to interact with GitHub API in PHP but none of this libraries provide a full support for all GitHub API features.

This library as been developed to help you to use all the features of GitHub API v3 easily as possible. This library, like the GitHub API is sparate in 2 distinct parts:

  1. The Client part who will be used to get informations about a repository, a user, a commit, …
  2. The Server part, called WebHooks that can be used to get events from GitHub API

This library provide the next features:

  • Supports all methods (Activity, Enterprise, Gists, Git Data, Issues, Miscellaneous, Organizations, Pull Requests, Repositories, Search, Users)
  • Supports Basic, OAuth and OAuth2 authentications.
  • Able to create a WebHooks server.
Minimum requirements

To run this library in your web server, you’ll need the most recent PHP version of the branch 5.6.x. for some security and dependencies reasons.

This library is only compatible with PHP 5.6.1 or above. So please upgrade your PHP version if you have a lower version installed.

You will also need the cURL extension enabled in your web server.


This library use some dependencies to work with.

Here are the dependencies this library need to be installed with:


To get the latest version of this GitHub API library simply use composer.

  1. You need to add this library to composer.json file:
$ php composer.phar require scion/githubapi
  1. Then you can install this library and all the dependencies using:
$ php composer.phar install
// This file is generated by Composer
require 'vendor/autoload.php';

// Create a Client object
$client = new \Scion\GitHub\Client();

Webhooks allow you to build or set up integrations which subscribe to certain events on GitHub.com.

Complete documentation is available at https://developer.github.com/webhooks/.

For using a WebHook, you need an instance of Scion\GitHub\WebHook class like:

// This file is generated by Composer
require 'vendor/autoload.php';

// Creating WebHook instance
$webhook = new \Scion\GitHub\WebHook();

This library supports all authentications provided by the GitHub API v3. You can use the Basic Authentication, OAuth Token or the OAuth2 Key/Secret pair authentication for the Client and WebHook classes, like described here:

Basic Authentication
// Username only

// Username & password
$client->setHttpAuth('username', 'password');
OAuth Token

Go to Authorized applications to Generate new token, then you will be able to provide your 'token'.

// sent in userpwd

// sent in a header
$client->setToken('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', \Scion\Github\Client::OAUTH2_HEADER_AUTH);

// sent as a parameter
$client->setToken('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', \Scion\Github\Client::OAUTH2_PARAMETERS_AUTH);
OAuth2 Key/Secret pair

Go to Authorized applications to Register new application, then you will be able to provide yours client_id and client_secret.

$client->setClientId(''); // Set client_id
$client->setClientSecret(''); // Set client_secret

You can find the full documentation of this library in the wiki section of the GitHub repository.

July 11, 2015

© 2013-2021 All rights reserved.

Built with Next.js. Designed with in Montreal