lemmon/kirby-gitstats
Composer 安装命令:
composer require lemmon/kirby-gitstats
包简介
Converts Kirby text fields into GitHub stats, giving you stars, forks and issue counts with a simple field method.
README 文档
README
Single-method helper for Kirby that exposes GitHub stats through any text field. Provide owner/repo or a full URL to receive stars, forks, watchers, open issues and other metadata, cached efficiently for repeated use.
Installation
Composer
composer require lemmon/kirby-gitstats
Git Submodule
git submodule add https://github.com/lemmon/kirby-plugin-gitstats.git site/plugins/gitstats
Manual
Download the plugin and extract it to /site/plugins/gitstats.
Usage
Add a text field to your blueprint and call the field method to fetch stats:
fields: repository: label: Repository type: text placeholder: lemmon/validator-php
<?php if ($stats = $page->repository()->toGitStats()): ?> <dl> <dt>Stars</dt><dd><?= $stats['stars'] ?></dd> <dt>Forks</dt><dd><?= $stats['forks'] ?></dd> <dt>Watchers</dt><dd><?= $stats['watchers'] ?></dd> <dt>Open issues</dt><dd><?= $stats['open_issues'] ?></dd> <dt>URL</dt><dd><a href="<?= $stats['url'] ?>"><?= $stats['url'] ?></a></dd> </dl> <?php endif; ?>
Accepted field values:
- GitHub shorthand:
lemmon/validator-php - Full URL:
https://github.com/lemmon/validator-php
The first release defaults to GitHub. Other providers may follow later.
Returned fields
Each successful call returns an associative array similar to:
[ 'provider' => 'github', 'slug' => 'lemmon/validator-php', 'owner' => 'lemmon', 'name' => 'validator-php', 'full_name' => 'lemmon/validator-php', 'description' => 'Lightweight validator', 'url' => 'https://github.com/lemmon/validator-php', 'homepage' => null, 'stars' => 123, 'forks' => 4, 'watchers' => 8, 'open_issues' => 2, 'language' => 'PHP', 'default_branch' => 'main', 'updated_at' => '2024-05-01T17:42:08Z', ]
Null is returned when the value cannot be parsed or the repository is not reachable.
Configuration
| Option | Default | Purpose |
|---|---|---|
lemmon.gitstats.cacheTtlLower |
1440 (24h) |
Preferred refresh interval in minutes; cached data newer than this is returned without refresh. |
lemmon.gitstats.cacheTtlUpper |
10080 (7d) |
Hard cache lifetime in minutes; entries older than this are refreshed and persisted again. |
lemmon.gitstats.cacheRetryDelay |
60 (1h) |
Retry/backoff window in minutes used when GitHub refresh fails; cached data is reused until it passes. |
Example Kirby config override:
return [ 'lemmon.gitstats.cacheTtlLower' => 1440, // refresh roughly daily 'lemmon.gitstats.cacheTtlUpper' => 20160, // keep entries up to 14 days 'lemmon.gitstats.cacheRetryDelay' => 30, // backoff for 30 minutes after a failed refresh ];
Retry and provider backoff
- When cached data is older than
cacheTtlLower, a refresh is attempted. - If GitHub responds or times out with an error, the plugin reuses cached data, sets
next_refresh_atfor that repository, and marks GitHub as temporarily down forcacheRetryDelayminutes. - While GitHub is marked down, other repositories served from cache skip refresh attempts; they resume after the backoff window.
Roadmap
- Add support for other common Git providers (GitLab, Bitbucket, Gitea).
- Introduce a CLI helper to refresh cached stats in the background.
- When refresh attempts fail after
cacheTtlLoweris met, reuse cached data and delay the next refresh (e.g., 1h or the nextcacheTtlLowerwindow).
License
MIT License. See LICENSE for details.
lemmon/kirby-gitstats 适用场景与选型建议
lemmon/kirby-gitstats 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「git」 「repository」 「github」 「kirby」 「kirby-plugin」 「kirby-cms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 lemmon/kirby-gitstats 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lemmon/kirby-gitstats 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 lemmon/kirby-gitstats 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Handles basic OAuth/OAuth2 authentication along with classes for common services
repository php library
Easily manage git hooks in your composer config
MediaWiki extension that allows embedding external content, specified by URL, into your wiki pages
Nagios plugin to verify a git repository.
Laravel 5 - Repositories to the database layer
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-19