Piwik\

Config

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.

Examples

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();

Methods

The class defines the following methods:

__get()

Returns a configuration value or section by name.

Signature

  • It accepts the following parameter(s):

    • $name (string) — The value or section name.
  • Returns: string|array — The requested value requested. Returned by reference.

  • It throws one of the following exceptions:
    • Exception — If the value requested not found in either config.ini.php or global.ini.php.

getFromGlobalConfig()

Signature

  • It accepts the following parameter(s):

    • $name
  • It does not return anything or a mixed result.

getFromCommonConfig()

Signature

  • It accepts the following parameter(s):

    • $name
  • It does not return anything or a mixed result.

getFromLocalConfig()

Signature

  • It accepts the following parameter(s):

    • $name
  • It does not return anything or a mixed result.

__set()

Sets a configuration value or section.

Signature

  • 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.

Signature

  • It does not return anything or a mixed result.