PHP Class Piwik\Config

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();
Inheritance: extends piwik\Singleton
Show file Open project: piwik/piwik Class Usage Examples

Protected Properties

Property Type Description
$doNotWriteConfigInTests boolean
$settings Piwik\Application\Kernel\GlobalSettingsProvider

Public Methods

Method Description
__construct ( Piwik\Application\Kernel\GlobalSettingsProvider $settings )
__get ( string $name ) : string | array Returns a configuration value or section by name.
__set ( string $name, mixed $value ) Sets a configuration value or section.
clear ( ) Clear in-memory configuration so it can be reloaded
deleteLocalConfig ( )
dumpConfig ( ) : string | null Dump config
existsLocalConfig ( )
forceSave ( ) Writes the current configuration to the **config.ini.php** file. Only writes options whose values are different from the default.
forceUsageOfLocalHostnameConfig ( string $hostname ) : string If set, Piwik will use the hostname config no matter if it exists or not. Useful for instance if you want to create a new hostname config:
getByDomainConfigPath ( )
getClientSideOptions ( )
getCommonConfigPath ( ) : string Returns absolute path to the common configuration file.
getCommonPath ( ) : string Returns the path to the common config file used by this instance.
getConfigHostnameIfSet ( )
getConfigNotWritableException ( )
getFromCommonConfig ( $name )
getFromGlobalConfig ( $name )
getFromLocalConfig ( $name )
getGlobalConfigPath ( ) : string Returns absolute path to the global configuration file
getGlobalPath ( ) : string Returns the path to the global config file used by this instance.
getHostname ( ) : string Returns the hostname of the current request (without port number)
getInstance ( ) : Config
getLocalConfigPath ( ) : string Returns absolute path to the local configuration file
getLocalPath ( ) : string Returns the path to the local config file used by this instance.
init ( ) Read configuration from files into memory
isFileWritable ( ) : boolean Returns true if the local configuration file is writable.

Protected Methods

Method Description
reload ( $pathLocal = null, $pathGlobal = null, $pathCommon = null ) Reloads config data from disk.
writeConfig ( boolean $clear = true ) Write user configuration file

Private Methods

Method Description
getDatatableRowLimits ( ) : mixed
getLocalConfigInfoForHostname ( $hostname )

Method Details

__construct() public method

public __construct ( Piwik\Application\Kernel\GlobalSettingsProvider $settings )
$settings Piwik\Application\Kernel\GlobalSettingsProvider

__get() public method

Returns a configuration value or section by name.
public __get ( string $name ) : string | array
$name string The value or section name.
return string | array The requested value requested. Returned by reference.

__set() public method

Sets a configuration value or section.
public __set ( string $name, mixed $value )
$name string This section name or value name to set.
$value mixed

clear() public method

Clear in-memory configuration so it can be reloaded
Deprecation: since v2.12.0
public clear ( )

deleteLocalConfig() public method

public deleteLocalConfig ( )

dumpConfig() public method

Dump config
public dumpConfig ( ) : string | null
return string | null

existsLocalConfig() public method

Deprecation:
public existsLocalConfig ( )

forceSave() public method

Writes the current configuration to the **config.ini.php** file. Only writes options whose values are different from the default.
public forceSave ( )

forceUsageOfLocalHostnameConfig() public method

$config = Config::getInstance(); $config->forceUsageOfHostnameConfig('piwik.example.com'); $config->save();
public forceUsageOfLocalHostnameConfig ( string $hostname ) : string
$hostname string eg piwik.example.com
return string

getByDomainConfigPath() public static method

public static getByDomainConfigPath ( )

getClientSideOptions() public method

getCommonConfigPath() public static method

Returns absolute path to the common configuration file.
public static getCommonConfigPath ( ) : string
return string

getCommonPath() public method

Returns the path to the common config file used by this instance.
public getCommonPath ( ) : string
return string

getConfigHostnameIfSet() public method

getConfigNotWritableException() public method

getFromCommonConfig() public method

public getFromCommonConfig ( $name )

getFromGlobalConfig() public method

public getFromGlobalConfig ( $name )

getFromLocalConfig() public method

public getFromLocalConfig ( $name )

getGlobalConfigPath() public static method

Returns absolute path to the global configuration file
public static getGlobalConfigPath ( ) : string
return string

getGlobalPath() public method

Returns the path to the global config file used by this instance.
public getGlobalPath ( ) : string
return string

getHostname() public static method

Returns the hostname of the current request (without port number)
public static getHostname ( ) : string
return string

getInstance() public static method

public static getInstance ( ) : Config
return Config

getLocalConfigPath() public static method

Returns absolute path to the local configuration file
public static getLocalConfigPath ( ) : string
return string

getLocalPath() public method

Returns the path to the local config file used by this instance.
public getLocalPath ( ) : string
return string

init() public method

Read configuration from files into memory
Deprecation: since v2.12.0
public init ( )

isFileWritable() public method

Returns true if the local configuration file is writable.
public isFileWritable ( ) : boolean
return boolean

reload() protected method

Reloads config data from disk.
protected reload ( $pathLocal = null, $pathGlobal = null, $pathCommon = null )

writeConfig() protected method

Write user configuration file
protected writeConfig ( boolean $clear = true )
$clear boolean

Property Details

$doNotWriteConfigInTests protected property

protected bool $doNotWriteConfigInTests
return boolean

$settings protected property

protected GlobalSettingsProvider,Piwik\Application\Kernel $settings
return Piwik\Application\Kernel\GlobalSettingsProvider