You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
864 B
PHP
37 lines
864 B
PHP
<?php
|
|
|
|
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()
|
|
{
|
|
$config = $this->app->make(Config::class);
|
|
$this->app->instance(Config::class, $config);
|
|
$this->app->instance('config', $config);
|
|
|
|
foreach ($this->configFiles as $file) {
|
|
$file = config_path($file);
|
|
|
|
if (!file_exists($file)) {
|
|
continue;
|
|
}
|
|
|
|
$config->set(array_replace_recursive(
|
|
$config->get(null),
|
|
require $file
|
|
));
|
|
}
|
|
|
|
if (empty($config->get(null))) {
|
|
throw new Exception('Configuration not found');
|
|
}
|
|
}
|
|
}
|