Piwik\
Singleton that provides read & write access to Matomo (formerly Piwik)'s INI configuration.
This class reads and writes to the config/config.ini.php
file. If config
options are missing from that file, this class will look for their default
values in config/global.ini.php
.
Getting a value:
// read the minimum_memory_limit option under the [General] section
$minValue = Config::getInstance()->General['minimum_memory_limit'];
Setting a value:
// set the minimum_memory_limit option
Config::getInstance()->General['minimum_memory_limit'] = 256;
Config::getInstance()->forceSave();
Setting an entire section:
Config::getInstance()->MySection = array('myoption' => 1);
Config::getInstance()->forceSave();
The class defines the following methods:
__get()
— Returns a configuration value or section by name.getFromGlobalConfig()
getFromCommonConfig()
getFromLocalConfig()
__set()
— Sets a configuration value or section.forceSave()
— Writes the current configuration to the config.ini.php file.__get()
Returns a configuration value or section by name.
It accepts the following parameter(s):
$name
(string
) —
The value or section name.Returns: string
|array
—
The requested value requested. Returned by reference.
Exception
— If the value requested not found in either config.ini.php
or
global.ini.php
.getFromGlobalConfig()
It accepts the following parameter(s):
$name
It does not return anything or a mixed result.
getFromCommonConfig()
It accepts the following parameter(s):
$name
It does not return anything or a mixed result.
getFromLocalConfig()
It accepts the following parameter(s):
$name
It does not return anything or a mixed result.
__set()
Sets a configuration value or section.
It accepts the following parameter(s):
$name
(string
) —
This section name or value name to set.$value
(mixed
) —It does not return anything or a mixed result.
forceSave()
Writes the current configuration to the config.ini.php file. Only writes options whose values are different from the default.