Dietcube\Application::loadConfig PHP Method

loadConfig() public method

public loadConfig ( )
    public function loadConfig()
    {
        $config = [];
        foreach ($this->getConfigFiles() as $config_file) {
            $load_config_file = $this->getConfigDir() . '/' . $config_file;
            if (!file_exists($load_config_file)) {
                continue;
            }
            $config = array_merge($config, require $load_config_file);
        }
        $this->config = new Config($config);
        $this->bootConfig();
    }

Usage Example

Example #1
0
 public function boot()
 {
     $this->app->loadConfig();
     $container = $this->container = new Container();
     $this->container['event_dispatcher'] = $this->event_dispatcher = new EventDispatcher();
     $this->container['app'] = $this->app;
     $this->app->setContainer($container);
     $config = $this->container['app.config'] = $this->app->getConfig();
     $this->container['logger'] = $logger = $this->app->createLogger($config->get('logger.path'), $config->get('logger.level', Logger::WARNING));
     $logger->debug('Application booted. env={env}', ['env' => $this->app->getEnv()]);
     $logger->debug('Config file loaded. config_files={files}', ['files' => implode(',', $this->app->getConfigFiles())]);
     $this->bootGlobals();
     $this->app->initHttpRequest($this->container);
     $this->app->init($this->container);
     if (!isset($this->container['router'])) {
         $this->container['router'] = new Router($this->container);
         $this->container['router']->addRoute($this->app->getRoute());
     }
     if (!isset($this->container['app.renderer'])) {
         $this->container['app.renderer'] = function () {
             return $this->createRenderer();
         };
     }
     $this->app->config($this->container);
     $this->event_dispatcher->dispatch(DietcubeEvents::BOOT, new BootEvent($this->app));
 }