inital commit
[pharext/pharext.org] / app / bootstrap / config.php
1 <?php
2
3 use merry\Config;
4
5 $injector->share(Config::class)
6 ->define(Config::class, [
7 ":array" => parse_ini_file(__DIR__."/../config.ini", true),
8 ":section" => getenv("APP_ENVIRONMENT")
9 ])
10 ->prepare(Config::class, function(Config $config) {
11 $credentials = parse_ini_file(__DIR__."/../credentials.ini", true);
12 foreach (new Config($credentials, getenv("APP_ENVIRONMENT")) as $app => $creds) {
13 /* one level down should suffice, i.e. $config->github->client = {id,secret,scope} */
14 if ($creds instanceof Config) {
15 foreach ($creds as $key => $val) {
16 $config->$app->$key = $val;
17 }
18 } else {
19 $config->$app = $creds;
20 }
21 }
22 });