Config

Configs are initial settings used to configure some of the parameters of the application.

The Quantum comes with solid solution of defining and reading config values using its Config class.

Because of hierarchical nature of the framework, the Quantum will try to the fetch configuration values from `Config/config.php` file of current module and if not found it will check them in base `config/config.php` file.

Config files are set of key/value pairs and has structure similar to this:


return array(
    'langs' => ['en', 'ru', 'am'],
    'lang_default' => 'en',
    'version' => env("APP_VERSION", '1.1'),
);

        

By default the Quantum loads only `config.php` file from current module and from base, but you can create separate configuration files and import them using import($filename) method of Config class from anywhere you like, by passing the path to the config file:


    Config::import(BASE_DIR . '/config/email.php');

        

Once configurations are loaded and/or imported you can access them via get($key, $default = NULL) method of Config class:


    $langDefault = Config::get('lang_default');

        

Quantum has also helper method to access to config values:


    $langDefault = get_config('lang_default');

        

Sometimes you may want to get all the config values to loop through or just dump it out, for that purposes you can use the all() method of Config class:


    $allConfigs = Config::all();

        
<< Prev Next >>