PHPackages                             jeffersongoncalves/laravel-github-client - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. jeffersongoncalves/laravel-github-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

jeffersongoncalves/laravel-github-client
========================================

A lightweight GitHub REST API client for Laravel with tri-state repository status detection and built-in rate-limit handling.

v1.1.0(1mo ago)158MITPHPPHP ^8.2CI passing

Since Jun 20Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/jeffersongoncalves/laravel-github-client)[ Packagist](https://packagist.org/packages/jeffersongoncalves/laravel-github-client)[ GitHub Sponsors](https://github.com/jeffersongoncalves)[ RSS](/packages/jeffersongoncalves-laravel-github-client/feed)WikiDiscussions master Synced 2w ago

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

[![Laravel GitHub Client](https://raw.githubusercontent.com/jeffersongoncalves/laravel-github-client/master/art/jeffersongoncalves-laravel-github-client.png)](https://raw.githubusercontent.com/jeffersongoncalves/laravel-github-client/master/art/jeffersongoncalves-laravel-github-client.png)

Laravel GitHub Client
=====================

[](#laravel-github-client)

[![Tests](https://github.com/jeffersongoncalves/laravel-github-client/actions/workflows/run-tests.yml/badge.svg)](https://github.com/jeffersongoncalves/laravel-github-client/actions/workflows/run-tests.yml)[![PHPStan](https://github.com/jeffersongoncalves/laravel-github-client/actions/workflows/phpstan.yml/badge.svg)](https://github.com/jeffersongoncalves/laravel-github-client/actions/workflows/phpstan.yml)[![Code Style](https://github.com/jeffersongoncalves/laravel-github-client/actions/workflows/fix-php-code-style-issues.yml/badge.svg)](https://github.com/jeffersongoncalves/laravel-github-client/actions/workflows/fix-php-code-style-issues.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/71e7ec8849fdfb5dabd3fd4d9ea44ba6e3355f8a3f2bdc4193d22303acbdf5fd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6566666572736f6e676f6e63616c7665732f6c61726176656c2d6769746875622d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jeffersongoncalves/laravel-github-client)[![Total Downloads](https://camo.githubusercontent.com/011ba71ca147e43c7393da130e6eee255ff9dfee894b7c8ace2c147ebac0f006/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a6566666572736f6e676f6e63616c7665732f6c61726176656c2d6769746875622d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jeffersongoncalves/laravel-github-client)[![License](https://camo.githubusercontent.com/0ec0918f96efefdbb8c3bd2d68cf6b63519ab8d7a7ff0caef8474fb6c92c9655/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a6566666572736f6e676f6e63616c7665732f6c61726176656c2d6769746875622d636c69656e742e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

A lightweight GitHub REST API client for Laravel. It wraps the `api.github.com` and `raw.githubusercontent.com` calls behind a small static client, threads your API token, and centralises rate-limit detection so callers get a thrown `GitHubRateLimitException` rather than a silent failure during a limit window.

Features
--------

[](#features)

- **Tri-state repo status** — `repoStatus()` distinguishes a definitive 404 (`gone`) from a transient/unknown failure (`unknown`) so you never prune on doubt
- **Repository metadata** — `fetchRepo()` and `fetchDefaultBranchForSlug()`
- **README detection** — `subdirectoryHasReadme()` for monorepo subfolders
- **Raw content** — `fetchManifest()` to read JSON files and `fileExists()` to HEAD a path without downloading it
- **Branch listing** — `fetchBranches()` returns the branch names
- **Rate-limit aware** — throws `GitHubRateLimitException` on a primary (403 + `X-RateLimit-Remaining: 0`) or secondary (403/429 + `Retry-After`) limit, carrying the `retryAfter` seconds

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

[](#installation)

```
composer require jeffersongoncalves/laravel-github-client
```

Optionally publish the config file:

```
php artisan vendor:publish --tag="github-client-config"
```

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

[](#configuration)

Add to your `.env`:

```
GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx
```

Create a [Personal Access Token](https://github.com/settings/tokens/new) to lift the unauthenticated rate limit and access private repositories.

### Config Options

[](#config-options)

```
// config/github-client.php
return [
    'token' => env('GITHUB_TOKEN'),
    'user_agent' => env('GITHUB_USER_AGENT', 'laravel-github-client'),
    'timeout' => (int) env('GITHUB_TIMEOUT', 8),
];
```

When `github-client.token` is null the client falls back to `config('services.github.token')`.

Usage
-----

[](#usage)

```
use JeffersonGoncalves\GitHubClient\GitHubClient;
use JeffersonGoncalves\GitHubClient\Exceptions\GitHubRateLimitException;

// Tri-state existence probe
$status = GitHubClient::repoStatus('jeffersongoncalves/laravel-github-client');
// GitHubClient::REPO_EXISTS | REPO_GONE | REPO_UNKNOWN

// Repository metadata
$repo = GitHubClient::fetchRepo('jeffersongoncalves/laravel-github-client');
$branch = GitHubClient::fetchDefaultBranchForSlug('jeffersongoncalves/laravel-github-client');

// Branches
$branches = GitHubClient::fetchBranches('jeffersongoncalves/laravel-github-client');

// Raw content
$composer = GitHubClient::fetchManifest('jeffersongoncalves/laravel-github-client', 'main', 'composer.json');
$hasDockerfile = GitHubClient::fileExists('jeffersongoncalves/laravel-github-client', 'main', 'Dockerfile');

// Monorepo README detection
$hasReadme = GitHubClient::subdirectoryHasReadme('alpinejs/alpine', 'packages/anchor');
```

### Handling rate limits

[](#handling-rate-limits)

```
try {
    $status = GitHubClient::repoStatus('owner/repo');
} catch (GitHubRateLimitException $e) {
    // Back off for $e->retryAfter seconds (queue jobs can release($e->retryAfter)).
}
```

Testing
-------

[](#testing)

```
composer test
```

Static Analysis
---------------

[](#static-analysis)

```
composer analyse
```

Code Formatting
---------------

[](#code-formatting)

```
composer format
```

Changelog
---------

[](#changelog)

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

License
-------

[](#license)

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

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance91

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% 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 ~1 days

Total

2

Last Release

44d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/411493?v=4)[Jefferson Gonçalves](/maintainers/jeffersongoncalves)[@jeffersongoncalves](https://github.com/jeffersongoncalves)

---

Top Contributors

[![jeffersongoncalves](https://avatars.githubusercontent.com/u/411493?v=4)](https://github.com/jeffersongoncalves "jeffersongoncalves (5 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

composergithubgithub-apihttp-clientjeffersongoncalveslaravellaravel-packagephprate-limithttpclientlaravelrestgithubrate limitGitHub-API

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/jeffersongoncalves-laravel-github-client/health.svg)

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

###  Alternatives

[spatie/laravel-medialibrary

Associate files with Eloquent models

6.2k45.4M679](/packages/spatie-laravel-medialibrary)[spatie/laravel-health

Monitor the health of a Laravel application

88212.7M180](/packages/spatie-laravel-health)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

24773.9k](/packages/harris21-laravel-fuse)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

817336.8k3](/packages/defstudio-telegraph)[nativephp/mobile

NativePHP for Mobile

1.1k102.1k123](/packages/nativephp-mobile)[api-platform/laravel

API Platform support for Laravel

58174.6k18](/packages/api-platform-laravel)

PHPackages © 2026

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