X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=README.md;h=ca82ab313e3378e675d4fd5ae777f8cc9cc8e6ad;hb=HEAD;hp=27f04d52bbf1a0d8b4d80a8d52b6d27bcdfede07;hpb=c4dee6a78ed1a44f83472b3523bfaa4c53e26161;p=m6w6%2Fseekat diff --git a/README.md b/README.md index 27f04d5..ffee664 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,26 @@ # seekat -Fluent Github API access with PHP-7 and [ext-http](https://github.com/m6w6/ext-http). [![Build Status](https://travis-ci.org/m6w6/seekat.svg)](https://travis-ci.org/m6w6/seekat) +Fluent Github API access with [ext-http](https://github.com/m6w6/ext-http). + +Support for the following promise providers built in: + * [ReactPHP](https://github.com/reactphp/promise) + * [AmPHP](https://github.com/amphp/amp) + +Supports plugging into your favourite event loop through +[http\Client's custom event loop interface](https://mdref.m6w6.name/http/Client/Curl/User). + +Simple example: + ```php repos->m6w6->seekat->readme->as("html")->then(function($readme) { +$api = new API(API\Future\react()); + +$api->repos->m6w6->seekat->readme->as("html")->then(function($readme) { echo $readme; }, function($error) { echo $error; @@ -17,7 +29,59 @@ use seekat\API; $api->send(); ``` -> ***Note:*** WIP +Full example: + +```php +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; + } +}); +``` ## Installing @@ -29,7 +93,7 @@ $api->send(); ## ChangeLog A comprehensive list of changes can be obtained from the -[releases overview](./releases). +[releases overview](https://github.com/m6w6/seekat/releases). ## License