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