summaryrefslogtreecommitdiff
path: root/src/Config
diff options
context:
space:
mode:
Diffstat (limited to 'src/Config')
-rw-r--r--src/Config/ConfigServiceProvider.php21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/Config/ConfigServiceProvider.php b/src/Config/ConfigServiceProvider.php
index 21cbbeb6..63f43ced 100644
--- a/src/Config/ConfigServiceProvider.php
+++ b/src/Config/ConfigServiceProvider.php
@@ -3,25 +3,34 @@
namespace Engelsystem\Config;
use Engelsystem\Container\ServiceProvider;
+use Exception;
class ConfigServiceProvider extends ServiceProvider
{
+ /** @var array */
+ protected $configFiles = ['config.default.php', 'config.php'];
+
public function register()
{
- $defaultConfigFile = config_path('config.default.php');
- $configFile = config_path('config.php');
-
$config = $this->app->make(Config::class);
$this->app->instance(Config::class, $config);
$this->app->instance('config', $config);
- $config->set(require $defaultConfigFile);
+ foreach ($this->configFiles as $file) {
+ $file = config_path($file);
+
+ if (!file_exists($file)) {
+ continue;
+ }
- if (file_exists($configFile)) {
$config->set(array_replace_recursive(
$config->get(null),
- require $configFile
+ require $file
));
}
+
+ if (empty($config->get(null))) {
+ throw new Exception('Configuration not found');
+ }
}
}