PHPackages                             oneduo/github-sdk-php - 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. oneduo/github-sdk-php

ActiveLibrary[API Development](/categories/api)

oneduo/github-sdk-php
=====================

PHP SDK for the GitHub REST API – OpenAPI based and fully typed for seamless integration

v0.1.5(11mo ago)3456↓50%[2 PRs](https://github.com/oneduo/github-sdk-php/pulls)MITPHPPHP ^8.2CI passing

Since Jun 6Pushed 4mo agoCompare

[ Source](https://github.com/oneduo/github-sdk-php)[ Packagist](https://packagist.org/packages/oneduo/github-sdk-php)[ Docs](https://github.com/oneduo/github-sdk-php)[ GitHub Sponsors](https://github.com/oneduo)[ RSS](/packages/oneduo-github-sdk-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (7)Versions (7)Used By (0)

GitHub SDK for PHP
==================

[](#github-sdk-for-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ec30771afbac339c7e315adffba7144116f081520eb74710814fb85b6892c6c5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6e6564756f2f6769746875622d73646b2d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oneduo/github-sdk-php)[![GitHub Tests Action Status](https://camo.githubusercontent.com/f3ca292e3f27b673cb4811b4f709188a1511d37d3fb3fa90f73a554756b24773/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6f6e6564756f2f6769746875622d73646b2d7068702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/oneduo/github-sdk-php/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/051a94cf56b67cfc15717cd80ef7f71b793f2ff20945f850ae72e789ca5fda65/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6f6e6564756f2f6769746875622d73646b2d7068702f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/oneduo/github-sdk-php/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/ab92fc17b83554fd532522c376c509e3fca7ae431bee53e212e48dc65bb8226a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6e6564756f2f6769746875622d73646b2d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oneduo/github-sdk-php)

A fully typed, modern PHP client for the [GitHub REST API v3](https://docs.github.com/en/rest), built on top of [Saloon](https://docs.saloon.dev/). This SDK provides a clean, intuitive, and fluent interface for interacting with all GitHub API endpoints, leveraging Saloon's powerful features for authentication, request building, and extensibility.

Installation
------------

[](#installation)

Install via Composer:

```
composer require oneduo/github-sdk-php
```

Documentation
-------------

[](#documentation)

- **GitHub REST API:**
- **Saloon Documentation:**

Basic Usage
-----------

[](#basic-usage)

### Initialize the Connector

[](#initialize-the-connector)

```
use Oneduo\GitHubSdk\GitHubConnector;

$github = new GitHubConnector();
```

### Example: Fetch a Public Repository (No Authentication Required)

[](#example-fetch-a-public-repository-no-authentication-required)

```
$response = $github->repos()->get('octocat', 'hello-world');
$repository = $response->json();
```

### Example: List Public Users (No Authentication Required)

[](#example-list-public-users-no-authentication-required)

```
$response = $github->users()->list();
$users = $response->json();
```

### Example: Get User Information (No Authentication Required)

[](#example-get-user-information-no-authentication-required)

```
$response = $github->users()->getByUsername('octocat');
$user = $response->json();
```

Authentication
--------------

[](#authentication)

This SDK supports the most common authentication methods for the GitHub API using Saloon authenticators:

### Bearer Token Authentication (Recommended for GitHub)

[](#bearer-token-authentication-recommended-for-github)

The `TokenAuthenticator` class adds an `Authorization: Bearer` header to requests:

```
use Saloon\Http\Auth\TokenAuthenticator;

$github = new GitHubConnector();
$github->authenticate(new TokenAuthenticator('your-github-token'));

// Now you can access authenticated endpoints
$response = $github->users()->getAuthenticated();
$user = $response->json();
```

### Basic Auth (Base64 Encoded)

[](#basic-auth-base64-encoded)

```
use Saloon\Http\Auth\BasicAuthenticator;

$github = new GitHubConnector();
$github->authenticate(new BasicAuthenticator('your-username', 'your-password'));

// Now you can access authenticated endpoints
$response = $github->users()->getAuthenticated();
$user = $response->json();
```

### GitHub App Authentication

[](#github-app-authentication)

For GitHub Apps, you can use the included `AppAuthenticator` that generates JWT tokens:

```
use Oneduo\GitHubSdk\Authenticators\AppAuthenticator;

// Using a private key file path
$github = new GitHubConnector();
$github->authenticate(new AppAuthenticator(
    appId: 'your-app-id',
    key: '/path/to/your/private-key.pem'
));

// Or using key content directly
$github = new GitHubConnector();
$github->authenticate(new AppAuthenticator(
    appId: 'your-app-id',
    key: '-----BEGIN RSA PRIVATE KEY-----...'
));

// With passphrase if your key is encrypted
$github = new GitHubConnector();
$github->authenticate(new AppAuthenticator(
    appId: 'your-app-id',
    key: '/path/to/your/private-key.pem',
    passphrase: 'your-passphrase'
));

// Using an existing OpenSSLAsymmetricKey resource (PHP 8.0+)
$keyResource = openssl_pkey_get_private(file_get_contents('/path/to/key.pem'));
$github = new GitHubConnector();
$github->authenticate(new AppAuthenticator(
    appId: 'your-app-id',
    key: $keyResource
));

// Now you can access GitHub App endpoints
$response = $github->apps()->getAuthenticated();
$app = $response->json();
```

The `AppAuthenticator` supports:

- **File paths**: String path to your private key file
- **Key content**: Raw private key content as a string
- **OpenSSL resources**: `OpenSSLAsymmetricKey` objects (PHP 8.0+)
- **Passphrases**: Optional encryption passphrase for protected keys

For more authentication strategies (query, certificate, header, multiple, custom, etc.), see the [Saloon Authentication Documentation](https://docs.saloon.dev/the-basics/authentication).

Advanced Usage
--------------

[](#advanced-usage)

### Example: List Repositories for an Organization

[](#example-list-repositories-for-an-organization)

```
$github->authenticate(new TokenAuthenticator('your-github-token'));
$response = $github->repos()->listForOrg('oneduo');
$repos = $response->json();
```

### Example: Create a Repository (Authenticated)

[](#example-create-a-repository-authenticated)

```
$github->authenticate(new TokenAuthenticator('your-github-token'));
$response = $github->repos()->createForAuthenticatedUser([
    'name' => 'my-new-repo',
    'private' => true,
]);
$newRepo = $response->json();
```

Custom Requests
---------------

[](#custom-requests)

You can send custom requests using Saloon's request system. For example, to call an undocumented or custom endpoint:

```
use Saloon\Http\Request;
use Saloon\Enums\Method;

class MyCustomRequest extends Request {
    protected Method $method = Method::GET;

    public function resolveEndpoint(): string {
        return '/rate_limit';
    }
}

$response = $github->send(new MyCustomRequest());
$data = $response->json();
```

Tip

Explore [Saloon's documentation](https://docs.saloon.dev/) for more on custom requests, plugins, and advanced features.

More Examples
-------------

[](#more-examples)

- [GitHub REST API Reference](https://docs.github.com/en/rest)
- [Saloon Usage Examples](https://docs.saloon.dev/)

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Contributions are welcome! Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Charaf Rezrazi](https://github.com/Rezrazi)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance66

Regular maintenance activity

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80.8% 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 ~0 days

Total

4

Last Release

345d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cf9fd13f4d32603791fb5ba1796ba8f04c843b99dfa35310ed1499806adc333?d=identicon)[mikaelpopowicz](/maintainers/mikaelpopowicz)

![](https://www.gravatar.com/avatar/fab6b46363863a2d820c53377e8941ede51db95f6680b9bf506ad192652300c8?d=identicon)[Rezrazi](/maintainers/Rezrazi)

---

Top Contributors

[![Rezrazi](https://avatars.githubusercontent.com/u/2086576?v=4)](https://github.com/Rezrazi "Rezrazi (21 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

phplaravelsdkgithuboneduogithub-sdk-php

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/oneduo-github-sdk-php/health.svg)

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

###  Alternatives

[edbizarro/laravel-facebook-ads

Facebook &amp; Instagram Ads for Laravel 5.6+

13629.5k](/packages/edbizarro-laravel-facebook-ads)[octw/aramex

A Library to integrate with Aramex APIs

2925.2k](/packages/octw-aramex)[wxm/taobao-sdk

淘宝 SDK 封装, 调用简单、语义化增强。支持 Laravel/Lumen。

1710.1k](/packages/wxm-taobao-sdk)[wxm/pdd-sdk

拼多多 SDK 封装, 调用简单、语义化增强。支持 Laravel/Lumen。

154.7k](/packages/wxm-pdd-sdk)

PHPackages © 2026

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