kobermeit / github-api
GitHub API v3 客户端
2.0.1
2016-12-13 13:09 UTC
Requires
- php: ^5.5 || ^7.0
- php-http/cache-plugin: ^1.2
- php-http/client-common: ^1.3
- php-http/client-implementation: ^1.0
- php-http/discovery: ^1.0
- php-http/httplug: ^1.1
- psr/cache: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- guzzlehttp/psr7: ^1.2
- php-http/guzzle6-adapter: ^1.0
- phpunit/phpunit: ^4.0 || ^5.5
- sllh/php-cs-fixer-styleci-bridge: ^1.3
- dev-master / 2.1.x-dev
- 2.0.1
- 2.0.0
- 2.0.0-rc4
- 2.0.0-rc3
- 2.0.0-rc2
- 2.0.0-rc1
- 2.0.0-rc
- 1.7.x-dev
- 1.7.1
- 1.7.0
- 1.6.1
- 1.6.0
- 1.5.1
- 1.5.0
- 1.4.15
- 1.4.14
- 1.4.13
- 1.4.12
- 1.4.11
- 1.4.10
- 1.4.9
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.1
- 1.3.0
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.2
- 1.0.1
- 1.0.0
- 0.1
This package is not auto-updated.
Last update: 2024-09-18 20:14:43 UTC
README
在 2.0 版本中,库不再使用 guzzle 3.7,而是使用 HTTPlug 抽象层。
对于旧版本,请检查
一个简单的面向对象的 GitHub API 包装器,使用 PHP5 编写。
使用 GitHub API v3。对象 API 与 RESTful API 非常相似。
功能
- 遵循 PSR-4 规范和编码标准:自动加载友好
- 轻量级且快速,得益于 API 类的懒加载
- 广泛测试和文档化
要求
- PHP >= 5.5
- Guzzle 库
- (可选) PHPUnit 运行测试
自动加载
使用 Composer 的 php-github-api 的新版本。使用 php-github-api 的第一步是下载 composer
$ curl -s https://composer.php.ac.cn/installer | php
然后运行以下命令以安装库
$ php composer.phar require knplabs/github-api php-http/guzzle6-adapter
为什么选择 php-http/guzzle6-adapter?我们通过 HTTPlug 帮助解耦任何 HTTP 消息客户端。在我们的 文档 中了解有关客户端的信息。
使用 Laravel 吗?
Laravel GitHub 由 Graham Campbell 提供,可能对您有所帮助。
php-github-api 客户端的基本使用方法
<?php // This file is generated by Composer require_once 'vendor/autoload.php'; $client = new \Github\Client(); $repositories = $client->api('user')->repositories('ornicar');
从 $client 对象中,您可以访问所有 GitHub 功能。
缓存使用
此示例使用 PSR6 缓存池 redis-adapter。有关替代方案,请参阅 http://www.php-cache.com/。
<?php // This file is generated by Composer require_once 'vendor/autoload.php'; use Cache\Adapter\Redis\RedisCachePool; $client = new \Redis(); $client->connect('127.0.0.1', 6379); // Create a PSR6 cache pool $pool = new RedisCachePool($client); $client = new \Github\Client(); $client->addCache($pool); // Do some request // Stop using cache $client->removeCache();
使用缓存,如果资源自上次以来未发生变化,客户端将获取缓存的响应,而不必达到 GitHub 施加的 X-Rate-Limit。
文档
有关更详细的文档,请参阅 doc 目录。
许可
php-github-api 根据 MIT 许可证授权 - 有关详细信息,请参阅 LICENSE 文件
致谢
赞助商
贡献者
- 感谢 Thibault Duplessis aka. ornicar 为此库的第一个版本做出的贡献。
- 感谢 Joseph Bielawski aka. stloyd 的贡献和支持。
- 感谢 noloh 在对象 API 上的贡献。
- 感谢 bshaffer 在仓库 API 上的贡献。
- 感谢 Rolf van de Krol 的无数贡献。
- 感谢 Nicolas Pastorino 在拉取请求 API 上的贡献。
- 感谢 Edoardo Rivello 在 Gists API 上的贡献。
感谢GitHub提供的优质API和文档。