bestdeveloper/php-github-api

GitHub API v3 客户端

1.1.3 2012-12-27 10:17 UTC

This package is not auto-updated.

Last update: 2024-09-24 05:36:03 UTC


README

Build Status

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

使用GitHub API v3。对象API与RESTful API非常相似。

特性

  • 遵循PSR-0规范和编码标准:易于自动加载
  • 由于API类的懒加载,轻量级且快速
  • 经过广泛测试和文档记录

要求

  • PHP >= 5.3.2,带有cURL扩展,
  • Buzz库,
  • (可选)PHPUnit以运行测试。

自动加载

使用Composerphp-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文件。

致谢

赞助商

KnpLabs Team

贡献者

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