ca82ab313e3378e675d4fd5ae777f8cc9cc8e6ad
[m6w6/seekat] / README.md
1 # seekat
2
3 [![Build Status](https://travis-ci.org/m6w6/seekat.svg)](https://travis-ci.org/m6w6/seekat)
4
5 Fluent Github API access with PHP-7 and [ext-http](https://github.com/m6w6/ext-http).
6
7 Support for the following promise providers built in:
8 * [ReactPHP](https://github.com/reactphp/promise)
9 * [AmPHP](https://github.com/amphp/amp)
10
11 Supports plugging into your favourite event loop through
12 [http\Client's custom event loop interface](https://mdref.m6w6.name/http/Client/Curl/User).
13
14 Simple example:
15
16 ```php
17 <?php
18
19 use seekat\API;
20
21 $api = new API(API\Future\react());
22
23 $api->repos->m6w6->seekat->readme->as("html")->then(function($readme) {
24 echo $readme;
25 }, function($error) {
26 echo $error;
27 });
28
29 $api->send();
30 ```
31
32 Full example:
33
34 ```php
35 <?php
36
37 require_once __DIR__."/../vendor/autoload.php";
38
39 use seekat\API;
40 use function seekat\API\Links\next;
41
42 $cli = new http\Client("curl", "seekat");
43 $cli->configure([
44 "max_host_connections" => 10,
45 "max_total_connections" => 50,
46 ]);
47
48 $log = new Monolog\Logger("seekat");
49 $log->pushHandler(new Monolog\Handler\StreamHandler(STDERR, Monolog\Logger::WARNING));
50
51 $api = new API(API\Future\react(), [
52 "Authorization" => "token ".getenv("GITHUB_TOKEN")
53 ], null, $cli, $log);
54
55 $api(function($api) {
56 $repos = yield $api->users->m6w6->repos([
57 "visibility" => "public",
58 "affiliation" => "owner"
59 ]);
60 while ($repos) {
61 $next = next($repos);
62
63 $batch = [];
64 foreach ($repos as $repo) {
65 $batch[] = $repo->hooks();
66 }
67 foreach (yield $batch as $key => $hooks) {
68 if (!count($hooks)) {
69 continue;
70 }
71 printf("%s:\n", $repos->{$key}->name);
72 foreach ($hooks as $hook) {
73 if ($hook->name == "web") {
74 printf("\t%s\n", $hook->config->url);
75 } else {
76 printf("\t%s\n", $hook->name);
77 }
78 }
79 }
80
81 $repos = yield $next;
82 }
83 });
84 ```
85
86
87 ## Installing
88
89 ### Composer
90
91 composer require m6w6/seekat
92
93 ## ChangeLog
94
95 A comprehensive list of changes can be obtained from the
96 [releases overview](https://github.com/m6w6/seekat/releases).
97
98 ## License
99
100 seekat is licensed under the 2-Clause-BSD license, which can be found in
101 the accompanying [LICENSE](./LICENSE) file.
102
103 ## Contributing
104
105 All forms of contribution are welcome! Please see the bundled
106 [CONTRIBUTING](./CONTRIBUTING.md) note for the general principles followed.
107
108 The list of past and current contributors is maintained in [THANKS](./THANKS).