PHPackages                             krzysztofzylka/github - 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. krzysztofzylka/github

ActiveLibrary[API Development](/categories/api)

krzysztofzylka/github
=====================

PHP GitHub API client library

1.0.2(9mo ago)01.4k↑646.2%MITPHPPHP &gt;=8.0

Since Jul 19Pushed 9mo agoCompare

[ Source](https://github.com/krzysztofzylka/github)[ Packagist](https://packagist.org/packages/krzysztofzylka/github)[ RSS](/packages/krzysztofzylka-github/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

GitHub API Client Library
=========================

[](#github-api-client-library)

A PHP library for interacting with the GitHub API v3. This library provides a simple and intuitive interface for working with GitHub repositories, users, issues, pull requests, and more.

Features
--------

[](#features)

- **Authentication**: Support for Personal Access Tokens, OAuth tokens, and Basic authentication
- **Repository Management**: Create, update, delete repositories and manage branches
- **Issue Management**: Create, update, close, and manage issues
- **Pull Request Management**: Create, update, merge pull requests
- **User Management**: Get user information and manage user data
- **Organization Management**: Work with GitHub organizations
- **Authorization**: Check permissions and token validity
- **Rate Limiting**: Built-in rate limit handling
- **Pagination**: Automatic pagination for large result sets

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

[](#installation)

```
composer require krzysztozylka/github
```

Quick Start
-----------

[](#quick-start)

### Basic Usage

[](#basic-usage)

```
use krzysztofzylka\github\Github;
use krzysztofzylka\github\Auth\TokenAuth;

// Create authentication
$auth = new TokenAuth('your-personal-access-token');

// Initialize GitHub client
$github = new Github($auth);

// Get authenticated user
$user = $github->users()->me();

// Get repository information
$repo = $github->repositories()->get('owner', 'repository-name');

// List issues
$issues = $github->issues()->all('owner', 'repository-name');
```

### Authentication Methods

[](#authentication-methods)

#### Personal Access Token

[](#personal-access-token)

```
use krzysztofzylka\github\Auth\TokenAuth;

$auth = new TokenAuth('your-personal-access-token');
```

#### OAuth Token

[](#oauth-token)

```
use krzysztofzylka\github\Auth\OAuthAuth;

$auth = new OAuthAuth('your-oauth-token');
```

#### Basic Authentication (Deprecated)

[](#basic-authentication-deprecated)

```
use krzysztofzylka\github\Auth\BasicAuth;

$auth = new BasicAuth('username', 'password');
```

API Examples
------------

[](#api-examples)

### Repository Operations

[](#repository-operations)

```
// Get repository
$repo = $github->repositories()->get('owner', 'repo-name');

// Create repository
$newRepo = $github->repositories()->create([
    'name' => 'new-repository',
    'description' => 'Repository description',
    'private' => false
]);

// List user repositories
$repos = $github->repositories()->listUserRepos('username');

// List branches
$branches = $github->repositories()->listBranches('owner', 'repo-name');

// Create branch
$branch = $github->repositories()->createBranch('owner', 'repo-name', 'new-branch', 'commit-sha');
```

### Issue Operations

[](#issue-operations)

```
// List issues
$issues = $github->issues()->all('owner', 'repo-name', [
    'state' => 'open',
    'labels' => 'bug'
]);

// Create issue
$issue = $github->issues()->create('owner', 'repo-name', [
    'title' => 'Bug report',
    'body' => 'Issue description',
    'labels' => ['bug', 'help wanted']
]);

// Update issue
$updatedIssue = $github->issues()->update('owner', 'repo-name', 123, [
    'title' => 'Updated title'
]);

// Close issue
$github->issues()->close('owner', 'repo-name', 123);
```

### Pull Request Operations

[](#pull-request-operations)

```
// List pull requests
$prs = $github->pullRequests()->all('owner', 'repo-name', [
    'state' => 'open'
]);

// Create pull request
$pr = $github->pullRequests()->create('owner', 'repo-name', [
    'title' => 'Feature implementation',
    'head' => 'feature-branch',
    'base' => 'main',
    'body' => 'Pull request description'
]);

// Merge pull request
$github->pullRequests()->merge('owner', 'repo-name', 123, [
    'merge_method' => 'squash'
]);
```

### User Operations

[](#user-operations)

```
// Get authenticated user
$user = $github->users()->me();

// Get user by username
$user = $github->users()->get('username');

// Update user profile
$updatedUser = $github->users()->update([
    'name' => 'New Name',
    'bio' => 'Updated bio'
]);

// List user organizations
$orgs = $github->users()->organizations('username');
```

### Authorization and Permissions

[](#authorization-and-permissions)

```
// Check token scopes
$scopes = $github->authorization()->getScopes();

// Check if token has specific scope
if ($github->authorization()->hasScope('repo')) {
    // Can access private repositories
}

// Check if token can perform action
if ($github->authorization()->canPerformAction('create_repo')) {
    // Can create repositories
}

// Get rate limit information
$rateLimit = $github->authorization()->getRateLimit();

// Check if token is valid
if ($github->authorization()->isTokenValid()) {
    // Token is working
}
```

Error Handling
--------------

[](#error-handling)

The library throws standard PHP exceptions for API errors:

```
try {
    $repo = $github->repositories()->get('owner', 'non-existent-repo');
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
    echo "Code: " . $e->getCode();
}
```

Rate Limiting
-------------

[](#rate-limiting)

The library automatically handles GitHub's rate limiting:

```
// Get current rate limit information
$rateLimit = $github->getClient()->getRateLimit();

echo "Limit: " . $rateLimit['limit'];
echo "Remaining: " . $rateLimit['remaining'];
echo "Reset time: " . date('Y-m-d H:i:s', $rateLimit['reset']);
```

Pagination
----------

[](#pagination)

For endpoints that return large result sets, the library automatically handles pagination:

```
// Get all repositories (automatically paginated)
$allRepos = $github->repositories()->listUserRepos('username');

// Limit pagination to specific number of pages
$limitedRepos = $github->getClient()->paginate('/user/repos', [], 5);
```

Requirements
------------

[](#requirements)

- PHP 8.0 or higher
- cURL extension
- JSON extension

License
-------

[](#license)

MIT License

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

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance57

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 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 ~29 days

Total

3

Last Release

280d ago

### Community

Maintainers

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

---

Top Contributors

[![krzysztofzylka](https://avatars.githubusercontent.com/u/41385342?v=4)](https://github.com/krzysztofzylka "krzysztofzylka (6 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/krzysztofzylka-github/health.svg)

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

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

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