jeffersongoncalves/laravel-github-stats
Composer 安装命令:
composer require jeffersongoncalves/laravel-github-stats
包简介
Self-hosted Laravel package that serves dynamic SVG cards with your GitHub statistics. Replace unreliable third-party services with your own.
README 文档
README
Laravel GitHub Stats
Self-hosted Laravel package that serves dynamic SVG cards with your GitHub statistics. Replace unreliable third-party services (github-readme-stats, streak-stats, github-profile-trophy) with your own private service.
Features
- Stats Card — Total Stars, Commits, PRs, Issues, Followers
- Top Languages Card — Horizontal bar chart with top 8 languages
- Streak Card — Current Streak, Longest Streak, Total Contributions
- Trophies Card — Achievement badges with rank levels (S/A/B/C/D)
- 6 Built-in Themes — tokyonight, dark, radical, merko, gruvbox, onedark
- Custom Colors — Override any color via query parameters
- Aggressive Caching — Two-layer cache (4h data + 1h SVG)
- Username Locked — Service locked to a single username via
.env - Background Refresh — Scheduled command to keep cache warm
Installation
composer require jeffersongoncalves/laravel-github-stats
Publish the config file:
php artisan vendor:publish --tag="github-stats-config"
Configuration
Add to your .env:
GITHUB_USERNAME=jeffersongoncalves GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx
Create a Personal Access Token with read:user scope. Add repo scope if you want private repository stats.
Config Options
// config/github-stats.php return [ 'username' => env('GITHUB_USERNAME', 'jeffersongoncalves'), 'token' => env('GITHUB_TOKEN'), 'cache' => [ 'data_ttl' => 14400, // 4 hours 'svg_ttl' => 3600, // 1 hour ], 'defaults' => [ 'theme' => 'tokyonight', 'hide_border' => false, 'show_icons' => true, 'langs_count' => 8, ], 'route_prefix' => 'api', 'middleware' => [], ];
Endpoints
| Method | Route | Description | Response |
|---|---|---|---|
| GET | /api/stats |
GitHub stats card | SVG |
| GET | /api/top-langs |
Top languages card | SVG |
| GET | /api/streak |
Contribution streak card | SVG |
| GET | /api/trophies |
Achievement trophies card | SVG |
| GET | /api/health |
Service health check | JSON |
Query Parameters
| Param | Default | Options |
|---|---|---|
theme |
tokyonight |
dark, radical, merko, gruvbox, onedark, tokyonight |
hide_border |
false |
true, false |
bg_color |
per theme | Any hex (without #) |
title_color |
per theme | Any hex |
text_color |
per theme | Any hex |
icon_color |
per theme | Any hex |
Usage in GitHub README
<div align="center"> <img height="180em" src="https://stats.yourdomain.com/api/stats?theme=tokyonight&hide_border=true" /> <img height="180em" src="https://stats.yourdomain.com/api/top-langs?theme=tokyonight&hide_border=true" /> </div> <div align="center"> <img src="https://stats.yourdomain.com/api/streak?theme=tokyonight&hide_border=true" /> </div> <div align="center"> <img src="https://stats.yourdomain.com/api/trophies?theme=tokyonight" /> </div>
Cache Refresh
The package includes a scheduled command to keep the cache warm:
php artisan github:refresh
Add to your scheduler (in routes/console.php or app/Console/Kernel.php):
Schedule::command('github:refresh')->everyFourHours();
Deployment
Option A — VPS with Forge/Ploi
- Provision a small VPS (1 vCPU, 1GB RAM)
- Deploy your Laravel app with this package
- Set
.envvariables - Setup Redis for caching
- Configure scheduler:
* * * * * php artisan schedule:run - Point subdomain:
stats.yourdomain.com - SSL via Let's Encrypt
Option B — Docker
services: app: build: . ports: ["8080:80"] environment: GITHUB_USERNAME: jeffersongoncalves GITHUB_TOKEN: ${GITHUB_TOKEN} depends_on: [redis] redis: image: redis:alpine
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.
jeffersongoncalves/laravel-github-stats 适用场景与选型建议
jeffersongoncalves/laravel-github-stats 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 40 次下载、GitHub Stars 达 3, 最近一次更新时间为 2026 年 02 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「github」 「stats」 「laravel」 「profile」 「svg」 「streak」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jeffersongoncalves/laravel-github-stats 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jeffersongoncalves/laravel-github-stats 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jeffersongoncalves/laravel-github-stats 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Helper to handle stats table with multiple formatter
Handles basic OAuth/OAuth2 authentication along with classes for common services
Rserve client library for PHP
MediaWiki extension that allows embedding external content, specified by URL, into your wiki pages
The Playground Stats module
X-Ray provides a comprehensive overview of the content present on your site and individual pages, allowing you to inspect and evaluate them at a glance.
统计信息
- 总下载量: 40
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 35
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-28
