summaryrefslogtreecommitdiff
path: root/src/Config/ConfigServiceProvider.php
blob: 01b648df9fec26726c7f925cac068a33a88f16c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php

namespace Engelsystem\Config;

use Engelsystem\Container\ServiceProvider;

class ConfigServiceProvider extends ServiceProvider
{
    public function register()
    {
        $defaultConfigFile = config_path('config.default.php');
        $configFile = config_path('config.php');

        $config = $this->app->make(Config::class);
        $this->app->instance('config', $config);

        $config->set(require $defaultConfigFile);

        if (file_exists($configFile)) {
            $config->set(array_replace_recursive(
                $config->get(null),
                require $configFile
            ));
        }
    }
}