From: Michael Wallner Date: Wed, 13 May 2015 08:47:04 +0000 (+0200) Subject: bail out if config cannot be parsed X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=2f593903bb0b095e3ecaece6c8e73ab3410af64f;p=pharext%2Fpharext.org bail out if config cannot be parsed --- diff --git a/.gitignore b/.gitignore index 379156e..b6a9719 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ nbproject app/credentials.ini config/credentials.ini logs/*.log +tmp/ diff --git a/app/bootstrap/config.php b/app/bootstrap/config.php index 3bc7f91..e4d4772 100644 --- a/app/bootstrap/config.php +++ b/app/bootstrap/config.php @@ -7,11 +7,18 @@ define("APP_ENVIRONMENT", getenv("APP_ENVIRONMENT") ?: "localhost"); $injector->share(Config::class) ->define(Config::class, [ "+array" => function($key, $injector) { - return parse_ini_file(__DIR__."/../../config/app.ini", true); + $settings = parse_ini_file(__DIR__."/../../config/app.ini", true); + if (!$settings) { + throw new \Exception("Could not parse settings"); + } + return $settings; }, ":section" => APP_ENVIRONMENT ]) ->prepare(Config::class, function($config, $injector) { $credentials = parse_ini_file(__DIR__."/../../config/credentials.ini", true); + if (!$credentials) { + throw new \Exception("Could not parse credentials"); + } $config->addConfig(new Config($credentials, APP_ENVIRONMENT)); });