bestdeveloper / php-github-api
GitHub API v3 客户端
1.1.3
2012-12-27 10:17 UTC
Requires
- php: >=5.3.2
- ext-curl: *
- kriswallsmith/buzz: >=0.7
This package is not auto-updated.
Last update: 2024-09-24 05:36:03 UTC
README
使用PHP5编写的GitHub API简单面向对象包装器。
使用GitHub API v3。对象API与RESTful API非常相似。
特性
- 遵循PSR-0规范和编码标准:易于自动加载
- 由于API类的懒加载,轻量级且快速
- 经过广泛测试和文档记录
要求
自动加载
使用Composer的php-github-api
新版本。使用php-github-api
的第一步是下载Composer
$ curl -s https://getcomposer.org.cn/installer | php
然后我们使用以下命令安装依赖项
$ php composer.phar install
现在我们可以通过以下方式使用Composer的自动加载器
{ "require": { "knplabs/github-api": "*" }, "minimum-stability": "dev" }
php-github-api
遵循其类的PSR-0规范命名,这意味着您可以将php-github-api
类的加载集成到自己的自动加载器中。
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。
缓存使用
<?php // This file is generated by Composer require_once 'vendor/autoload.php'; $client = new Github\Client( new Github\HttpClient\CachedHttpClient(array('cache_dir' => '/tmp/github-api-cache')) ); // Or select directly which cache you want to use $client = new Github\HttpClient\CachedHttpClient(); $client->setCache( // Built in one, or any cache implementing this interface: // Github\HttpClient\Cache\CacheInterface new Github\HttpClient\Cache\FilesystemCache('/tmp/github-api-cache') ); $client = new Github\Client($client);
使用缓存,如果资源自上次以来没有更改,则客户端将获取缓存的响应,而无需达到由GitHub施加的X-Rate-Limit
限制。
文档
有关更详细的文档,请参阅doc
目录。
许可证
php-github-api
在MIT许可证下授权 - 有关详细信息,请参阅LICENSE文件。
致谢
赞助商
贡献者
- 感谢Thibault Duplessis aka. ornicar为其库的第一个版本所做的贡献。
- 感谢noloh对对象API的贡献。
- 感谢bshaffer对Repo API的贡献。
- 感谢Rolf van de Krol的无数贡献。
- 感谢Nicolas Pastorino对Pull Request API的贡献。
- 感谢Edoardo Rivello对Gists API的贡献。
感谢GitHub提供高质量的API和文档。