bootstrap: more logging
[pharext/pharext.org] / app / bootstrap / github.php
1 <?php
2
3 namespace app;
4
5 require_once __DIR__."/config.php";
6 require_once __DIR__."/uri_template.php";
7 require_once __DIR__."/session.php";
8
9 use http\Url;
10
11 $injector->share(Github\API::class)
12 ->delegate(Github\API::class, function() use($injector) {
13 $config = $injector->make(Config::class);
14 if (isset($config->github->hook->use_basic_auth)) {
15 $basic = $config->github->hook->use_basic_auth;
16 $config->github->hook->url = (string) new Url(
17 $config->github->hook->url,
18 $config->$basic->auth->toArray(),
19 0);
20 }
21 $logger = new Logger($config, $config->github->log);
22
23 // FIXME: configure through app.ini
24 try {
25 $cache = new Github\Storage\Redis("gh-cache");
26 } catch (\Exception $ex) {
27 /* Memcached won't throw an exception */
28 $cache = new Github\Storage\Memcache("gh-cache");
29 }
30 return new Github\API(
31 $config->github
32 ,$logger
33 ,new Github\Storage\Session("gh-tokens")
34 ,$cache
35 );
36 });
37