From 21ffa2d775c959694776ee3f46f4e2d010a91e72 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Thu, 2 Jun 2016 17:49:55 +0200 Subject: [PATCH] fix README examples --- README.md | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 27f04d5..9dccecd 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,19 @@ # 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 PHP-7 and [ext-http](https://github.com/m6w6/ext-http). + +Simple example: + ```php repos->m6w6->seekat->readme->as("html")->then(function($readme) { +$api = new API; + +$api->repos->m6w6->seekat->readme->as("html")->then(function($readme) { echo $readme; }, function($error) { echo $error; @@ -17,6 +22,60 @@ use seekat\API; $api->send(); ``` +Full example: + +```php +configure([ + "max_host_connections" => 10, + "max_total_connections" => 50, +]); + +$log = new Monolog\Logger("seekat"); +$log->pushHandler((new Monolog\Handler\StreamHandler(STDERR))->setLevel(Monolog\Logger::WARNING)); + +$api = new API([ + "Authorization" => "token ".getenv("GITHUB_TOKEN") +], null, $cli, $log); + +$api(function($api) { + $repos = yield $api->users->m6w6->repos([ + "visibility" => "public", + "affiliation" => "owner" + ]); + while ($repos) { + $next = $repos->next(); + + $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; + } +}); +``` + + > ***Note:*** WIP @@ -29,7 +88,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 -- 2.30.2