PHPackages                             diversen/simple-php-github-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. diversen/simple-php-github-api

ActiveLibrary[API Development](/categories/api)

diversen/simple-php-github-api
==============================

simple php github api

1.1.3(10y ago)154386BSD-3-ClausePHPPHP &gt;=5.3.0

Since Apr 11Pushed 10y ago2 watchersCompare

[ Source](https://github.com/diversen/simple-php-github-api)[ Packagist](https://packagist.org/packages/diversen/simple-php-github-api)[ Docs](http://github.com/diversen/simple-php-github-api)[ RSS](/packages/diversen-simple-php-github-api/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (1)Versions (17)Used By (0)

About
=====

[](#about)

Very simple github API for PHP using OAuth. 37 LOC for the API class. And a curl helper class with 84 LOC.

Install `simple-php-github-api`
===============================

[](#install-simple-php-github-api)

```
php composer.phar require diversen/simple-php-github-api:

```

Or if you have placed composer.phar in `your path` as composer

```
composer require diversen/simple-php-github-api

```

Brief explantion.
=================

[](#brief-explantion)

There is really only tree methods you can do. Let us see those three methods first. (Further below is an complete example using the built-in server for easy testing).

1. Generate an access URL to github.com

```
$access_config = array (
    'redirect_uri' => GITHUB_CALLBACK_URL,
    'client_id' => GITHUB_ID,
    'state' =>  md5(uniqid()),
    'scope' => 'user'
);

$api = new githubapi();
$url = $api->getAccessUrl($access_config);
echo "Github Login";
```

2. Callback from github.com

```
$access_config = array (
    'redirect_uri' => GITHUB_CALLBACK_URL,
    'client_id' => GITHUB_ID,
    'client_secret' => GITHUB_SECRET
);

$api = new githubapi();
$res = $api->setAccessToken($access_config);

if ($res) {
    // OK
    This is where we will call the api
    header("Location: /api_call.php");
} else {
    // Not OK. echo errors
    echo "Could not get access token. Errors: ";
    print_r($api->errors);
}
```

3. API call

For full listing see:

```
// We have a access token and we can now call the api:
$api = new githubapi();

// Simple call - API get current users credentials
// This can also be done without scope

// example
// $command = '/user',
// $request = 'GET', 'POST' or 'PATCH' or 'DELETE' etc. Se API:
// $post = variables to POST array

$command = "/user";
$res = $api->apiCall($command, $request = null, $post = null);
if (!$res) {
    print_r($api->errors);
    die;
} else {
    print_r($res);
}
```

Full example
============

[](#full-example)

Example you can run right away using the built-in PHP-server.

Make a github app
-----------------

[](#make-a-github-app)

Log into [github.com](github.com)

Register a new application at

You will see something like this:

[![My settings](https://raw.githubusercontent.com/diversen/simple-php-github-api/master/github-api.png "My settings")](https://raw.githubusercontent.com/diversen/simple-php-github-api/master/github-api.png)

Create your app.

Enter base\_dir of the `simple-php-github-api`:

```
cd vendor/diversen/simple-php-github-api

```

Configuration
-------------

[](#configuration)

```
cp example/config.php-dist example/config.php

```

Edit config

Set config in `example/config.php` according to above settings and the screenshot above.

Run test-server with example:

```
php -S localhost:8080 -t example/

```

More github API info
--------------------

[](#more-github-api-info)

For full listing of all API calls check:

Scope:

I have not tested many calls - but you should be able to use all. E.g. POST, or PATCH, DELETE.

Support
-------

[](#support)

Create an issue, and Let me hear if it does not work out for you.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~69 days

Recently: every ~48 days

Total

16

Last Release

3787d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/23ed91d104f16d10414811ecdafbd5c80a660e658d80ccaadf84f512cfb50629?d=identicon)[diversen](/maintainers/diversen)

---

Top Contributors

[![diversen](https://avatars.githubusercontent.com/u/142675?v=4)](https://github.com/diversen "diversen (40 commits)")

---

Tags

github-apiapigithub

### Embed Badge

![Health badge](/badges/diversen-simple-php-github-api/health.svg)

```
[![Health](https://phpackages.com/badges/diversen-simple-php-github-api/health.svg)](https://phpackages.com/packages/diversen-simple-php-github-api)
```

###  Alternatives

[knplabs/github-api

GitHub API v3 client

2.2k16.8M206](/packages/knplabs-github-api)[evandotpro/edp-github

Github API integration module for Zend Framework 2

242.2k](/packages/evandotpro-edp-github)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
