2013-07-10 11:40:48 +02:00
|
|
|
# Application and Module Configuration
|
|
|
|
|
2013-08-28 13:31:18 +02:00
|
|
|
## Basic usage
|
|
|
|
|
2013-08-12 15:02:25 +02:00
|
|
|
The \Icinga\Application\Config class is a general purpose service to help you find, load and save
|
2013-07-10 11:40:48 +02:00
|
|
|
configuration data. It is used both by the Icinga 2 Web modules and the framework itself. With
|
|
|
|
INI files as source it enables you to store configuration in a familiar format. Icinga 2 Web
|
|
|
|
defines some configuration files for its own purposes. Please note that both modules and framework
|
|
|
|
keep their main configuration in the INI file called config.ini. Here's some example code:
|
|
|
|
|
|
|
|
<?php
|
2013-08-12 15:02:25 +02:00
|
|
|
use \Icinga\Application\Config as IcingaConfig;
|
2013-07-10 11:40:48 +02:00
|
|
|
|
|
|
|
// Retrieve the default timezone using 'Europe/Berlin' in case it is not set
|
|
|
|
IcingaConfig::app()->global->get('defaultTimezone', 'Europe/Berlin');
|
|
|
|
|
|
|
|
// If you don't pass a configuration name to IcingaConfig::app it tries to load values from the
|
|
|
|
// application's config.ini. For using other files you have to pass this parameter though.
|
|
|
|
// The following example loads a section from the application's authentication.ini:
|
|
|
|
IcingaConfig::app('authentication')->get('ldap-authentication');
|
|
|
|
|
|
|
|
// If you don't pass a configuration name to IcingaConfig::module it tries to load values from
|
|
|
|
// the module's config.ini. For using other files you have to pass this parameter though.
|
|
|
|
// The following example loads values from the example module's extra.ini:
|
|
|
|
IcingaConfig::module('example', 'extra')->logging->get('enabled', true);
|
|
|
|
|
2013-08-28 13:31:18 +02:00
|
|
|
## Reload from disk
|
|
|
|
|
|
|
|
If you want to force reading a configuration from disk (i.e. after you modified it), you can use the $fromDisk flag in
|
|
|
|
the IcingaConfig::app/IcingaConfig::module call:
|
|
|
|
|
|
|
|
IcingaConfig::app('authentication', true)-> ... // read authentication from disk
|
|
|
|
IcingaConfig::module('example', 'extra', true)->... // read module configuration from disk
|