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