A lightweight GitHub REST API client for Laravel with tri-state repository status detection and built-in rate-limit handling.
jeffersongoncalves/laravel-github-client is a Laravel package for a lightweight github rest api client for laravel with tri-state repository status detection and built-in rate-limit handling..
It currently has 1 GitHub stars and 1.796 downloads on Packagist (latest version v1.2.0).
Install it with composer require jeffersongoncalves/laravel-github-client.
Discover more Laravel packages by jeffersongoncalves
or browse all Laravel packages to compare alternatives.
Last updated

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.
repoStatus() distinguishes a definitive 404 (gone) from a transient/unknown failure (unknown) so you never prune on doubtfetchRepo() and fetchDefaultBranchForSlug()subdirectoryHasReadme() for monorepo subfoldersfetchManifest() to read JSON files and fileExists() to HEAD a path without downloading itfetchBranches() returns the branch names, following pagination up to $maxPages (default 10 × 100 branches, one REST call per page); fetchVersionBranches() returns only *.x branches in a single GraphQL call (token required)GitHubRateLimitException on a primary (403 + X-RateLimit-Remaining: 0) or secondary (403/429 + Retry-After) limit, carrying the retryAfter secondscomposer require jeffersongoncalves/laravel-github-client
Optionally publish the config file:
php artisan vendor:publish --tag="github-client-config"
Add to your .env:
GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx
Create a Personal Access Token to lift the unauthenticated rate limit and access private repositories.
// 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').
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'); // up to 10 pages
$versions = GitHubClient::fetchVersionBranches('jeffersongoncalves/laravel-github-client'); // ['1.x', '2.x', ...]
// 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');
try {
$status = GitHubClient::repoStatus('owner/repo');
} catch (GitHubRateLimitException $e) {
// Back off for $e->retryAfter seconds (queue jobs can release($e->retryAfter)).
}
composer test
composer analyse
composer format
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.
Get paid by clients abroad
Wise gives you local bank details in several currencies and converts at the mid-market rate. Useful when your invoices are not in your own currency.
Try WiseNew Laravel packages worth a look, once a month. No spam, one-click unsubscribe.