protected function loadConfigFolder() { # - iterate all the base config files and require # the files to return an array values $base_config_files = iterate_require(folder_files($this->path['config'])); # - iterate all the environment config files and # process the same thing as the base config files $env_config_files = iterate_require(folder_files($this->path['config'] . getenv('APP_ENV'))); # - merge the base config files and the environment # config files as one in the our DI 'config' config()->merge(new Config($base_config_files)); config()->merge(new Config($env_config_files)); }
/** * Load the configurations. * * @return $this */ public function loadConfig() { # let's create an empty config with just an empty # array, this is just for us to prepare the config $this->di->setShared('config', function () { return new Config([]); }); # get the paths and merge the array values to the # empty config as we instantiated above config(['path' => $this->paths]); # now merge the assigned environment config(['environment' => $this->getEnvironment()]); # iterate all the base config files and require # the files to return an array values $base_config_files = iterate_require(folder_files($this->paths['config'])); # iterate all the environment config files and # process the same thing as the base config files $env_config_files = iterate_require(folder_files(url_trimmer($this->paths['config'] . '/' . $this->getEnvironment()))); # merge the base config files and the environment # config files as one in the our DI 'config' config($base_config_files); config($env_config_files); return $this; }
/** * This loads the environment. * * @return \Clarity\Console\Brood */ protected function loadEnv() { $env = $this->getInput()->getOption('env'); $used_env = ''; $folder = ''; if (config('environment')) { $folder = $used_env = config('environment'); } if ($env !== null) { config(['old_environment' => config('environment')]); config(['environment' => $env]); $folder = $used_env = $env; } $folder_path = url_trimmer(config()->path->config . '/' . $folder); if (file_exists($folder_path) === false) { $this->error("Config Folder [{$used_env}] not found."); } config(iterate_require(folder_files($folder_path)), $merge = false); return $this; }