guillermoandrae/php-github

GitHub API 的 PHP 客户端库。

0.3.0 2015-03-11 02:08 UTC

This package is auto-updated.

Last update: 2024-09-29 04:49:09 UTC


README

Travis branch Coverage Status Code Quality HHVM

GitHub API 的 PHP 客户端库。GitHub API

安装

推荐使用 Composer 安装此库。

{
    "require": {
        "guillermoandrae/php-github": "*"
    }
}

基本用法

基本客户端使用 Guzzle 与 GitHub API 进行通信。客户端的实例化非常直接

// create the client
$client = new GitHub\Client\Client();

资源以对象的形式表示,并通过对象映射器获取资源数据

// pick a resource and get some useful data, like so...
$users = $client->resource('user')->findAll();
foreach ($users as $user) {
    printf('%s has %d followers.', $user->getLogin(), $user->getNumFollowers());
    echo PHP_EOL;
}

// or like so...
$org = $client->resource('organization')->find('github');
echo $org->getLocation();

// .. and rejoice!
echo 'YEESSSSSSSSSSSS!';