Config

class OC\Config
This class is responsible for reading and writing config.php, the very basic
configuration file of Nextcloud.
Source:lib/private/Config.php#46

Constants

ENV_PREFIX = NC_
Source:lib/private/Config.php#47

Properties

protected static property OC\Config::$cache
Source:lib/private/Config.php#50
Type:array Associative array ($key => $value)
protected static property OC\Config::$envCache
Source:lib/private/Config.php#52
Type:array
protected static property OC\Config::$configDir
Source:lib/private/Config.php#54
Type:string
protected static property OC\Config::$configFilePath
Source:lib/private/Config.php#56
Type:string
protected static property OC\Config::$configFileName
Source:lib/private/Config.php#58
Type:string

Methods

public OC\Config::__construct($configDir, $fileName=config.php)
Source:

lib/private/Config.php#64

Parameters:
  • $configDir (string) Path to the config dir, needs to end with ‘/’
  • $fileName (string) (Optional) Name of the config file. Defaults to config.php
public OC\Config::getKeys()
Lists all available config keys
Please note that it does not return the values.
Source:lib/private/Config.php#78
Returns:array an array of key names
public OC\Config::getValue($key, $default=null)
Returns a config value
gets its value from an `NC_` prefixed environment variable
if it doesn’t exist from config.php
if this doesn’t exist either, it will return the given `$default`
Source:

lib/private/Config.php#93

Parameters:
  • $key (string) key
  • $default (mixed) = null default value
Returns:

mixed the value or $default

public OC\Config::setValues($configs)
Sets and deletes values and writes the config.php
Source:

lib/private/Config.php#112

Parameters:
  • $configs (array) Associative array with key => value pairs

If value is null, the config key will be deleted

public OC\Config::setValue($key, $value)
Sets the value and writes it to config.php if required
Source:

lib/private/Config.php#134

Parameters:
  • $key (string) key
  • $value (mixed) value
protected OC\Config::set($key, $value)
This function sets the value
Source:

lib/private/Config.php#148

Parameters:
  • $key (string) key
  • $value (mixed) value
Returns:

bool True if the file needs to be updated, false otherwise

public OC\Config::deleteKey($key)
Removes a key from the config and removes it from config.php if required
Source:

lib/private/Config.php#162

Parameters:
  • $key (string)
protected OC\Config::delete($key)
This function removes a key from the config
Source:

lib/private/Config.php#175

Parameters:
  • $key (string)
Returns:

bool True if the file needs to be updated, false otherwise