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