bail out if config cannot be parsed
authorMichael Wallner <mike@php.net>
Wed, 13 May 2015 08:47:04 +0000 (10:47 +0200)
committerMichael Wallner <mike@php.net>
Wed, 13 May 2015 08:47:04 +0000 (10:47 +0200)
.gitignore
app/bootstrap/config.php

index 379156e13e814ee75bd636a20c886882a09b7faf..b6a97194d918256725d44d728754ace47d557a7c 100644 (file)
@@ -3,3 +3,4 @@ nbproject
 app/credentials.ini
 config/credentials.ini
 logs/*.log
+tmp/
index 3bc7f910667144c4c91f37c9d140cc57e5d05376..e4d47729b32f92647456fd55aa632238280cdec5 100644 (file)
@@ -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));
        });