jeffersongoncalves/laravel-github-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jeffersongoncalves/laravel-github-client

Composer 安装命令:

composer require jeffersongoncalves/laravel-github-client

包简介

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

README 文档

README

Laravel GitHub Client

Laravel GitHub Client

Tests PHPStan Code Style Latest Version on Packagist Total Downloads License

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

  • Tri-state repo statusrepoStatus() distinguishes a definitive 404 (gone) from a transient/unknown failure (unknown) so you never prune on doubt
  • Repository metadatafetchRepo() and fetchDefaultBranchForSlug()
  • README detectionsubdirectoryHasReadme() for monorepo subfolders
  • Raw contentfetchManifest() to read JSON files and fileExists() to HEAD a path without downloading it
  • Branch listingfetchBranches() 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

composer require jeffersongoncalves/laravel-github-client

Optionally publish the config file:

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

Configuration

Add to your .env:

GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx

Create a Personal Access Token to lift the unauthenticated rate limit and access private repositories.

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

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

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

Testing

composer test

Static Analysis

composer analyse

Code Formatting

composer format

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固