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.

10PHPCI passing

Since Jun 20Pushed today1 watchersCompare

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

READMEChangelog (1)DependenciesVersions (2)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

22

—

LowBetter than 21% of packages

Maintenance65

Regular maintenance activity

Popularity2

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 75% 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.

### 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 (3 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-limit

### 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

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25025.5M80](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.2M6.5k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k20.0k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87930.4k113](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.3M84](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69122.6k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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