m6w6/seekat

seekat 用 PHP 包装了 GitHub API

dev-master 2022-06-09 21:28 UTC

This package is auto-updated.

Last update: 2024-09-10 02:00:43 UTC


README

Build Status

使用 ext-http 实现流畅的 GitHub API 访问。

内置以下 Promise 提供者支持

通过 http\Client 的自定义事件循环接口 支持插入您喜欢的事件循环。

简单示例

<?php

use seekat\API;

$api = new API(API\Future\react());

$api->repos->m6w6->seekat->readme->as("html")->then(function($readme) {
	echo $readme;
}, function($error) {
	echo $error;
});

$api->send();

完整示例

<?php

require_once __DIR__."/../vendor/autoload.php";

use seekat\API;
use function seekat\API\Links\next;

$cli = new http\Client("curl", "seekat");
$cli->configure([
	"max_host_connections" => 10,
	"max_total_connections" => 50,
]);

$log = new Monolog\Logger("seekat");
$log->pushHandler(new Monolog\Handler\StreamHandler(STDERR, Monolog\Logger::WARNING));

$api = new API(API\Future\react(), [
	"Authorization" => "token ".getenv("GITHUB_TOKEN")
], null, $cli, $log);

$api(function($api) {
	$repos = yield $api->users->m6w6->repos([
		"visibility" => "public",
		"affiliation" => "owner"
	]);
	while ($repos) {
		$next = next($repos);

		$batch = [];
		foreach ($repos as $repo) {
			$batch[] = $repo->hooks();
		}
		foreach (yield $batch as $key => $hooks) {
			if (!count($hooks)) {
				continue;
			}
			printf("%s:\n", $repos->{$key}->name);
			foreach ($hooks as $hook) {
				if ($hook->name == "web") {
					printf("\t%s\n", $hook->config->url);
				} else {
					printf("\t%s\n", $hook->name);
				}
			}
		}

		$repos = yield $next;
	}
});

安装

Composer

composer require m6w6/seekat

变更日志

可以从中获得全面的变更列表 发布概览

许可协议

seekat 采用 2-Clause-BSD 许可协议,可在附带的 LICENSE 文件中找到。

贡献

欢迎所有形式的贡献!请参阅附带 CONTRIBUTING 笔记中遵循的一般原则。

过去的和当前的贡献者列表在 THANKS 中维护。