owenconti/github-api

GitHub API v3 客户端


README

Build Status StyleCI Latest Stable Version Total Downloads Latest Unstable Version Monthly Downloads Daily Downloads

使用 PHP 编写的简单面向对象的 GitHub API 包装器。

使用 GitHub API v3 & 支持 GitHub API v4。对象 API (v3) 与 RESTful API 非常相似。

特性

  • 轻量级且快速,得益于 API 类的懒加载
  • 广泛测试和文档化

需求

安装

通过 Composer

$ composer require knplabs/github-api php-http/guzzle6-adapter "^1.1"

为什么是 php-http/guzzle6-adapter?我们通过 HTTPlug 帮助解耦了任何 HTTP 消息客户端。在我们的 文档 中阅读有关客户端的信息。

使用 Laravel 吗?

Laravel GitHubGraham Campbell 提供,可能对您感兴趣。

php-github-api 客户端的基本用法

<?php

// This file is generated by Composer
require_once __DIR__ . '/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 __DIR__ . '/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 文件。

感谢

赞助商

KnpLabs Team

贡献者

感谢 GitHub 提供高质量的 API 和文档。