A GitHub API bridge for Laravel


Laravel GitHub

Laravel GitHub was created by, and is maintained by Graham Campbell, and is a PHP GitHub API bridge for Laravel. It utilises my Laravel Manager package. Feel free to check out the change log, releases, security policy, license, code of conduct, and contribution guidelines.


Promo Banner

Build Status StyleCI Status Software License Packagist Downloads Latest Version


Laravel GitHub requires PHP 7.2-8.0. This particular version supports Laravel 6-8.

GitHub L5.1 L5.2 L5.3 L5.4 L5.5 L5.6 L5.7 L5.8 L6 L7 L8

To get the latest version, simply require the project using Composer. You will need to install any packages that "provide" psr/http-client-implementation and psr/http-factory-implementation. Most users will want:

$ composer require "graham-campbell/github:^10.1" "guzzlehttp/guzzle:^7.2" "http-interop/http-factory-guzzle:^1.0"

If you'd like to use the private key authenticator, then you will also need to install lcobucci/jwt:

$ composer require lcobucci/jwt:^3.4


$ composer require lcobucci/jwt:^4.0

Once installed, if you are not using automatic package discovery, then you need to register the GrahamCampbell\GitHub\GitHubServiceProvider service provider in your config/app.php.

You can also optionally alias our facade:

        'GitHub' => GrahamCampbell\GitHub\Facades\GitHub::class,


Laravel GitHub requires connection configuration.

To get started, you'll need to publish all vendor assets:

$ php artisan vendor:publish

This will create a config/github.php file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.

There are two config options:

Default Connection Name

This option ('default') is where you may specify which of the connections below you wish to use as your default connection for all work. Of course, you may use many connections at once using the manager class. The default value for this setting is 'main'.

GitHub Connections

This option ('connections') is where each of the connections are setup for your application. Example configuration has been included, but you may add as many connections as you would like. Note that the 5 supported authentication methods are: "application", "jwt", "none", "private", and "token".

HTTP Cache

This option ('cache') is where each of the cache configurations setup for your application. Only the "illuminate" driver is provided out of the box. Example configuration has been included.



This is the class of most interest. It is bound to the ioc container as 'github' and can be accessed using the Facades\GitHub facade. This class implements the ManagerInterface by extending AbstractManager. The interface and abstract class are both part of my Laravel Manager package, so you may want to go and checkout the docs for how to use the manager class over at that repo. Note that the connection class returned will always be an instance of Github\Client.


This facade will dynamically pass static method calls to the 'github' object in the ioc container which by default is the GitHubManager class.


This class contains no public methods of interest. This class should be added to the providers array in config/app.php. This class will setup ioc bindings.

Real Examples

Here you can see an example of just how simple this package is to use. Out of the box, the default adapter is main. After you enter your authentication details in the config file, it will just work:

use GrahamCampbell\GitHub\Facades\GitHub;
// you can alias this in config/app.php if you like

// we're done here - how easy was that, it just works!

GitHub::repo()->show('GrahamCampbell', 'Laravel-GitHub');
// this example is simple, and there are far more methods available

The github manager will behave like it is a Github\Client class. If you want to call specific connections, you can do with the connection method:

use GrahamCampbell\GitHub\Facades\GitHub;

// the alternative connection is the other example provided in the default config
GitHub::connection('alternative')->me()->emails()->add('[email protected]');

// now we can see the new email address in the list of all the user's emails

With that in mind, note that:

use GrahamCampbell\GitHub\Facades\GitHub;

// writing this:
GitHub::connection('main')->issues()->show('GrahamCampbell', 'Laravel-GitHub', 2);

// is identical to writing this:
GitHub::issues()->show('GrahamCampbell', 'Laravel-GitHub', 2);

// and is also identical to writing this:
GitHub::connection()->issues()->show('GrahamCampbell', 'Laravel-GitHub', 2);

// this is because the main connection is configured to be the default
GitHub::getDefaultConnection(); // this will return main

// we can change the default connection
GitHub::setDefaultConnection('alternative'); // the default is now alternative

If you prefer to use dependency injection over facades like me, then you can easily inject the manager like so:

use GrahamCampbell\GitHub\GitHubManager;
use Illuminate\Support\Facades\App; // you probably have this aliased already

class Foo
    protected $github;

    public function __construct(GitHubManager $github)
        $this->github = $github;

    public function bar()
        $this->github->issues()->show('GrahamCampbell', 'Laravel-GitHub', 2);


For more information on how to use the Github\Client class we are calling behind the scenes here, check out the docs at https://github.com/KnpLabs/php-github-api/tree/v3.1.0/doc, and the manager class at https://github.com/GrahamCampbell/Laravel-Manager#usage.

Further Information

There are other classes in this package that are not documented here. This is because they are not intended for public use and are used internally by this package.


If you discover a security vulnerability within this package, please send an email to Graham Campbell at [email protected]. All security vulnerabilities will be promptly addressed. You may view our full security policy here.


Laravel GitHub is licensed under The MIT License (MIT).

For Enterprise

Available as part of the Tidelift Subscription

The maintainers of graham-campbell/github and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

  • repository lists incomplete

    repository lists incomplete

    Hi, quick question. When I call for a list of repos for a user the list returned is incomplete seems to cut off at 20 total.


    Is there anyway I can get it to return the entire list? thanks

    opened by sdeering 19
  • Implementation of private key authenticator

    Implementation of private key authenticator


    I tried to authorize for getting /apps/installations for Github App with different authorizations. But worked only my own implementation with generation of Bearer JWT token as described here: https://developer.github.com/apps/building-github-apps/authenticating-with-github-apps/

    opened by R3VoLuT1OneR 11
  • token coming from socialite

    token coming from socialite

    Hi Graham, I would like to use your api to manage repos but have the users tokens coming from socialite used instead of configured connections. Does the manager have the ability to do this or is this outside this scope of this product?

    Thanks, Nigel

    opened by njames 10
  • Error authenticating as GitHub application - 'Expiration time' claim ('exp') is too far in the future

    Error authenticating as GitHub application - 'Expiration time' claim ('exp') is too far in the future


    Every-so-often I get this error when trying to create an installation token for a GitHub App.

    $client = GitHubFacade::connection('private');

    GitHub specify a maximum expires value of 10 minutes: https://docs.github.com/en/[email protected]/developers/apps/authenticating-with-github-apps#authenticating-as-a-github-app

    The underlying code in this packages specifies a 9 minute 59 seconds value: https://github.com/GrahamCampbell/Laravel-GitHub/blob/10.0/src/Auth/Authenticator/PrivateKeyAuthenticator.php#L76

            $expires = $issued->add(
                new DateInterval('PT9M59S')

    My hypothesis is that (despite syncing with ntp) the internal clock on my server is drifting to >+1 seconds from UTC, resulting in a rejected expires value.

    As the use of this token is short lived, would you consider a PR to change this value to 9 minutes and 50 seconds? This would be less demanding on the accuracy between systems, but still expose larger discrepancies due to mis-configuration.


            $expires = $issued->add(
                new DateInterval('PT9M50S')

    Thank you for reading this issue. I am of course open to other suggestions!

    opened by jonmilsom 9
  • Getting token from db?

    Getting token from db?

    I have the github token in my db. It can be accessed using

    use Auth;
    $user = Auth::user();
    $token = $user->token;

    As (I think) you can't use some functions in config files, how can I archieve that?

    opened by m1guelpf 9
  • [Lumen] undefined function `config_path()'

    [Lumen] undefined function `config_path()'

    $ php artisan serve
    PHP Fatal error:  Call to undefined function GrahamCampbell\GitHub\config_path() in /path/to/project/vendor/graham-campbell/github/src/GitHubServiceProvider.php on line 43

    If I comment out the 43. line at ./vendor/graham-campbell/github/src/GitHubServiceProvider.php:43 my project, everything works as should.

    I saw that @GrahamCampbell has already dealt with this issue here.

         protected function setupConfig()
             $source = realpath(__DIR__.'/../config/github.php');
    -        $this->publishes([$source => config_path('github.php')]);
    +        // $this->publishes([$source => config_path('github.php')]);
             $this->mergeConfigFrom($source, 'github');
    opened by balintant 9
  • Service



    Since latest composer update I'm getting this error:

    Argument 1 passed to GrahamCampbell\GitHub\GitHubManager::__construct() must be an instance of Illuminate\Contracts\Config\Config, instance of Illuminate\Config\Repository given, called in /Users/nicolaswidart/Sites/Homestead/PortfolioV2/vendor/graham-campbell/github/src/GitHubServiceProvider.php on line 85 and defined

    Something I have to change?


    opened by nWidart 9
  • guzzlehttp/guzzle:^7.2 install issue with this

    guzzlehttp/guzzle:^7.2 install issue with this

    PHP version: 7.4.19 Description Tried to install with fresh new laravel (8.65) project when tried to run that command as instructed on documentation composer require "graham-campbell/github:^10.3" "guzzlehttp/guzzle:^7.2" "http-interop/http-factory-guzzle:^1.0"

    Log: ` Problem 1 - Root composer.json requires guzzlehttp/guzzle 7.2 -> satisfiable by guzzlehttp/guzzle[7.2.0]. - guzzlehttp/guzzle 7.2.0 requires guzzlehttp/psr7 ^1.7 -> found guzzlehttp/psr7[1.7.0, ..., 1.x-dev] but the package is fixed to 2.1.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command. Problem 2 - Root composer.json requires http-interop/http-factory-guzzle 1.0 -> satisfiable by http-interop/http-factory-guzzle[1.0.0]. - http-interop/http-factory-guzzle 1.0.0 requires guzzlehttp/psr7 ^1.4.2 -> found guzzlehttp/psr7[1.4.2, ..., 1.x-dev] but the package is fixed to 2.1.0 (lock file version) by a partial update and that version does not match. Ma ke sure you list it as an argument for the update command. Problem 3 - guzzlehttp/guzzle 7.2.0 requires guzzlehttp/psr7 ^1.7 -> found guzzlehttp/psr7[1.7.0, ..., 1.x-dev] but the package is fixed to 2.1.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command. - graham-campbell/github v10.3.0 requires knplabs/github-api 3.3.* -> satisfiable by knplabs/github-api[v3.3.0]. - knplabs/github-api v3.3.0 requires psr/http-client-implementation ^1.0 -> satisfiable by guzzlehttp/guzzle[7.2.0]. - Root composer.json requires graham-campbell/github 10.3 -> satisfiable by graham-campbell/github[v10.3.0].

    Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions. `

    How to reproduce Install laravel v8.65 Run composer require "graham-campbell/github:^10.3" "guzzlehttp/guzzle:^7.2" "http-interop/http-factory-guzzle:^1.0"

    Possible Solution with install updated version of guzzle. need to update readme composer require "graham-campbell/github:^10.3" "guzzlehttp/guzzle:^7.4" "http-interop/http-factory-guzzle:^1.1"

    opened by emtiazzahid 7
  • GitHub depreciating OAuth via query string

    GitHub depreciating OAuth via query string

    See this issue for the GH library this depends upon - GH is depreciating authentication via the query string and suggests HTTP Basic auth. For this laravel library, the ApplicationAuthenticator currently uses the depreciated method.


    From the above-linked issue, a drop-in fix should be changing the authMethod from AUTH_URL_CLIENT_ID to AUTH_HTTP_PASSWORD, however, this doesn't work for me (getting 'bad credentials') so I'm opening an issue instead of a PR.

    opened by judge2020 6
  • Mocking member functions

    Mocking member functions

    Hi! Maybe this doesnt belong here, but I'm very lost... I'm in Laravel 5.4, writing tests for my application, and I want to mock

    Github::api('organization')->members()->add($org->name, $this->argument('username'));

    I've tried with


    but it throws this error:

    1) Tests\Unit\JoinTest::testAuth
    Symfony\Component\Debug\Exception\FatalThrowableError: Call to a member function members() on null

    How can I do it?

    opened by m1guelpf 6
  • [question] Is there a way to do a query on a subresource? (hypermedia)

    [question] Is there a way to do a query on a subresource? (hypermedia)

    If for example I query a repository, and in that response there is an "issues_url" with the api endpoint required to get the issues for that particular repository... is there a way for me to call that endpoint with the api? I can't even find a way to do it manually.

    Here is an example of what the query I want looks like: https://api.github.com/repos/GrahamCampbell/Laravel-GitHub/issues{/number}

    I don't see any way to do this with the api... I tried doing it manually like this:

    $repo = $this->gitHubManager->repository()->showById(14735403); // getting a specific repo
    // then trying to get the issues for that specific repo
    $issues = $this->gitHubManager->getHttpClient()->get(uri_template($repo['issues_url'], [])); // <-- this doesn't work

    I'm just checking to see if there is something I'm missing.

    Thanks! Isaac

    opened by isaackearl 5
  • Projects V2 API

    Projects V2 API

    Hi! I'm trying to get the projects for my organization, and it comes up as if I haven't got any, which I have. GitHub::organizationProjects()->all('nameoforg');

    It just gives me an empty array, is this because the API is only for the Projects (Classic) API?

    opened by SrPeterr 0
  • 'Expiration time' claim ('exp') must be a numeric value representing the future time at which the assertion expires

    'Expiration time' claim ('exp') must be a numeric value representing the future time at which the assertion expires

    PHP version: 8.0.11

    Description I (occasionally) get the following error when attempting to authenticate as an app

    'Expiration time' claim ('exp') must be a numeric value representing the future time at which the assertion expires

    How to reproduce

    $github = resolve(GitHubManager::class);
    $installationId = $installationId ?: config('github.installations.' . $org);
    $token = $github
    $githubConnection = $github
                'token' => $token['token'],
                'method' => 'token',
                'cache' => 'main',
                'backoff' => true,
    return $githubConnection;

    Additional context I am acting as the app installation, but perhaps I am going about it in the wrong way and there is a way to authenticate as an app installation already built in

    opened by matthewnessworthy 8
Graham Campbell
OSS Maintainer | Laravel | StyleCI
Graham Campbell
A DigitalOcean API bridge for Laravel

Laravel DigitalOcean Laravel DigitalOcean was created by, and is maintained by Graham Campbell, and is a DigitalOcean PHP API Client bridge for Larave

Graham Campbell 421 Dec 20, 2022
[DEPRECATED] A Pusher Channels bridge for Laravel

DEPRECATED Laravel now has built-in support for Pusher Channels. This is now the recommended approach to integrate Channels into a Laravel project. Cu

Pusher 406 Dec 28, 2022
A simple PHP GitHub API client, Object Oriented, tested and documented.

PHP GitHub API A simple Object Oriented wrapper for GitHub API, written with PHP. Uses GitHub API v3 & supports GitHub API v4. The object API (v3) is

KNP Labs 2k Jan 7, 2023
PHP library for the GitHub API v3

GitHub API v3 - PHP Library Currently under construction. Overview Provides access to GitHub API v3 via an Object Oriented PHP library. The goal of th

Darren Rees 62 Jul 28, 2022
Generate pretty release changelogs using the commit log and Github API.

zenstruck/changelog Generate pretty release changelogs using the commit log and Github API. Changelog entries are in the following format: {short hash

Kevin Bond 3 Jun 20, 2022
Retrieve the GitHub Sponsors of a given user/organization.

Laravel GitHub Sponsors Retrieve the GitHub Sponsors of any user/organization and check if someone is sponsoring you. Installation composer require as

Astrotomic 7 Apr 27, 2022
GitHub Action to dynamically update CONTRIBUTORS file

Generate / Update CONTRIBUTORS File - GitHub Action This GitHub Action updates a CONTRIBUTORS file with the top contributors from the specified projec

minicli 86 Dec 21, 2022
A discord bot for creating github repo issues.

Discord Issue Bot A discord bot for creating github repo issues. Requires: php-zlib, php-json, mysql, composer Tested on: Ubuntu 20.04.3, PHP Version

null 1 Jan 20, 2022
This package is a simple API laravel wrapper for Pokemontcg with a sleek Model design for API routes and authentication.

This package is a simple API laravel wrapper for Pokemontcg with a sleek Model design for API routes and authentication.

Daniel Henze 3 Aug 29, 2022
DigitalOcean API v2 client for Symfony and API Platform

DigitalOcean Bundle for Symfony and API Platform DunglasDigitalOceanBundle allows using the DigitalOcean API from your Symfony and API Platform projec

Kévin Dunglas 25 Jul 27, 2022
API SDK for OpenTrade Commerce API: Taobao, Alibaba, JD, 1688, Aliexpress, Ebay.

OtapiPhpClient Create Client $client = new OtClient($key, $secret, $lang); key (Access Key) secret (Secret for access key) language (2 symbol lang id

OpenTrade Commerce 5 Sep 20, 2022
Fanmade project using Twitter API and Marvel API.

Project Marvel Memories A fanmade project in PHP using API Twitter V2, Marvel API and Github action scheduler. What about? Posts a random cover with d

Julien SCHMITT 15 Dec 17, 2022
Nexmo REST API client for PHP. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.

Client Library for PHP Support Notice This library and it's associated packages, nexmo/client and nexmo/client-core have transitioned into a "Maintena

Nexmo 75 Sep 23, 2022
API client for ThePay - payment gate API

This is the official highly compatible public package of The Pay SDK which interacts with The Pay's REST API. To get started see examples below.

ThePay.cz s.r.o. 3 Oct 27, 2022
Code Quiz MonoRepo (API, API Client, App)

Code Quiz Welcome to the Code Quiz Open Source project from How To Code Well. This is an Open Source project that includes an API and an App for the d

How To Code Well 2 Nov 20, 2022
A simple API documentation package for Laravel using OpenAPI and Redoc

Laravel Redoc Easily publish your API documentation using your OpenAPI document in your Laravel Application. Installation You can install this package

Steve McDougall 15 Dec 27, 2022
Integrate RajaOngkir API with laravel

Baca ini dalam bahasa: Indonesia This is my package laravel-rajaongkir Installation You can install the package via composer: composer require kodepin

Kode Pintar 6 Aug 11, 2022
🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.

Telegram Bot API - PHP SDK Telegram Bot PHP SDK lets you develop Telegram Bots in PHP easily! Supports Laravel out of the box. Telegram Bot API is an

Irfaq Syed 2.5k Jan 6, 2023
Twitch Helix API PHP Wrapper for Laravel

Laravel Twitch PHP Twitch Helix API Wrapper for Laravel 5+ ⚠️ Changes on May 01, 2020 Since May 01, 2020, Twitch requires all requests to contain a va

Roman Zipp 87 Dec 7, 2022