Class PEAR_Config

Description

This is a class for storing configuration data, keeping track of which are system-defined, user-defined or defaulted.

Located in /maintenance/libraries/pear/PEAR/Config.php (line 196)

PEAR
   |
   --PEAR_Config
Variable Summary
Method Summary
 PEAR_Config PEAR_Config ([string $user_file = ''], [string $system_file = ''])
 string definedBy (string $key)
 mixed get (string $key, [mixed $layer = null])
 void getConfFile (string $layer)
 string getDocs (string $key)
 string getGroup (string $key)
 array getGroupKeys (string $group)
 array getGroups ()
 array getKeys ()
 array getLayers ()
 string getPrompt (string $key)
 array getSetValues (string $key)
 string getType (string $key)
 bool isDefaulted (string $key)
 bool isDefined (string $key)
 bool isDefinedLayer (string $layer)
 bool mergeConfigFile (string $file, [bool $override = true], [string $layer = 'user'])
 bool readConfigFile ([string $file = null], [string $layer = 'user'])
 bool remove (string $key, [string $layer = 'user'])
 bool removeLayer (string $layer, string 1)
 bool set (string $key, string $value, [string $layer = 'user'])
 object an &singleton ([string $user_file = ''], [string $system_file = ''])
 bool store ([string $layer = 'user'], [mixed $data = null])
 bool toDefault (string $key)
 bool writeConfigFile ([string $file = null], [bool $layer = 'user'], [string $data = null])
 bool _decodeInput (array &$data)
 bool _encodeOutput (array &$data)
 array _readConfigDataFrom (string $file)
Variables
array $configuration = array(
'user' => array(),'system'=>array(),'default'=>array(),)
(line 224)

Configuration data, two-dimensional array where the first dimension is the config layer ('user', 'system' and 'default'), and the second dimension is keyname => value.

The order in the first dimension is important! Earlier layers will shadow later ones when a config value is requested (if a 'user' value exists, it will be returned first, then 'system' and finally 'default').

  • var: layer => array(keyname => value, ...)
array $configuration_info = array(
// Internet Access
'master_server' => array(
'type' => 'string',
'default' => 'pear.php.net',
'doc' => 'name of the main PEAR server',
'prompt' => 'PEAR server',
'group' => 'Internet Access',
),'http_proxy'=>array('type'=>'string','default'=>PEAR_CONFIG_DEFAULT_HTTP_PROXY,'doc'=>'HTTP proxy (host:port) to use when downloading packages','prompt'=>'HTTP Proxy Server Address','group'=>'Internet Access',),// File Locations
'php_dir'=>array('type'=>'directory','default'=>PEAR_CONFIG_DEFAULT_PHP_DIR,'doc'=>'directory where .php files are installed','prompt'=>'PEAR directory','group'=>'File Locations',),'ext_dir'=>array('type'=>'directory','default'=>PEAR_CONFIG_DEFAULT_EXT_DIR,'doc'=>'directory where loadable extensions are installed','prompt'=>'PHP extension directory','group'=>'File Locations',),'doc_dir'=>array('type'=>'directory','default'=>PEAR_CONFIG_DEFAULT_DOC_DIR,'doc'=>'directory where documentation is installed','prompt'=>'PEAR documentation directory','group'=>'File Locations',),'bin_dir'=>array('type'=>'directory','default'=>PEAR_CONFIG_DEFAULT_BIN_DIR,'doc'=>'directory where executables are installed','prompt'=>'PEAR executables directory','group'=>'File Locations',),'data_dir'=>array('type'=>'directory','default'=>PEAR_CONFIG_DEFAULT_DATA_DIR,'doc'=>'directory where data files are installed','prompt'=>'PEAR data directory','group'=>'File Locations (Advanced)',),'test_dir'=>array('type'=>'directory','default'=>PEAR_CONFIG_DEFAULT_TEST_DIR,'doc'=>'directory where regression tests are installed','prompt'=>'PEAR test directory','group'=>'File Locations (Advanced)',),'cache_dir'=>array('type'=>'directory','default'=>PEAR_CONFIG_DEFAULT_CACHE_DIR,'doc'=>'directory which is used for XMLRPC cache','prompt'=>'PEAR Installer cache directory','group'=>'File Locations (Advanced)',),'php_bin'=>array('type'=>'file','default'=>PEAR_CONFIG_DEFAULT_PHP_BIN,'doc'=>'PHP CLI/CGI binary for executing scripts','prompt'=>'PHP CLI/CGI binary','group'=>'File Locations (Advanced)',),// Maintainers
'username'=>array('type'=>'string','default'=>'','doc'=>'(maintainers) your PEAR account name','prompt'=>'PEAR username (for maintainers)','group'=>'Maintainers',),'password'=>array('type'=>'password','default'=>'','doc'=>'(maintainers) your PEAR account password','prompt'=>'PEAR password (for maintainers)','group'=>'Maintainers',),// Advanced
'verbose'=>array('type'=>'integer','default'=>PEAR_CONFIG_DEFAULT_VERBOSE,'doc'=>'verbosity level
0: really quiet
1: somewhat quiet
2: verbose
3: debug','prompt'=>'Debug Log Level','group'=>'Advanced',),'preferred_state'=>array('type'=>'set','default'=>PEAR_CONFIG_DEFAULT_PREFERRED_STATE,'doc'=>'the installer will prefer releases with this state when installing packages without a version or state specified','valid_set'=>array('stable','beta','alpha','devel','snapshot'),'prompt'=>'Preferred Package State','group'=>'Advanced',),'umask'=>array('type'=>'mask','default'=>PEAR_CONFIG_DEFAULT_UMASK,'doc'=>'umask used when creating files (Unix-like systems only)','prompt'=>'Unix file mask','group'=>'Advanced',),'cache_ttl'=>array('type'=>'integer','default'=>PEAR_CONFIG_DEFAULT_CACHE_TTL,'doc'=>'amount of secs where the local cache is used and not updated','prompt'=>'Cache TimeToLive','group'=>'Advanced',),'sig_type'=>array('type'=>'set','default'=>PEAR_CONFIG_DEFAULT_SIG_TYPE,'doc'=>'which package signature mechanism to use','valid_set'=>array('gpg'),'prompt'=>'Package Signature Type','group'=>'Maintainers',),'sig_bin'=>array('type'=>'string','default'=>PEAR_CONFIG_DEFAULT_SIG_BIN,'doc'=>'which package signature mechanism to use','prompt'=>'Signature Handling Program','group'=>'Maintainers',),'sig_keyid'=>array('type'=>'string','default'=>'','doc'=>'which key to use for signing with','prompt'=>'Signature Key Id','group'=>'Maintainers',),'sig_keydir'=>array('type'=>'string','default'=>PEAR_CONFIG_DEFAULT_SIG_KEYDIR,'doc'=>'which package signature mechanism to use','prompt'=>'Signature Key Directory','group'=>'Maintainers',),)
(line 237)

Information about the configuration data. Stores the type, default value and a documentation string for each configuration value.

  • var: layer => array(infotype => value, ...)
array $files = array(
'system' => '',
'user' => '',
)
(line 205)

Array of config files used.

  • var: layer => config file
mixed $layers = array() (line 210)
Methods
Constructor PEAR_Config (line 401)

Constructor.

  • see: PEAR_Config::singleton
  • access: public
PEAR_Config PEAR_Config ([string $user_file = ''], [string $system_file = ''])
  • string $user_file: (optional) file to read user-defined options from
  • string $system_file: (optional) file to read system-wide defaults from
definedBy (line 1078)

Tells what config layer that gets to define a key.

  • return: the config layer, or an empty string if not found
  • access: public
string definedBy (string $key)
  • string $key: config key
get (line 745)

Returns a configuration value, prioritizing layers as per the layers property.

  • return: the config value, or NULL if not found
  • access: public
mixed get (string $key, [mixed $layer = null])
  • string $key: config key
getConfFile (line 652)

Gets the file used for storing the config for a layer

void getConfFile (string $layer)
  • string $layer: 'user' or 'system'
getDocs (line 842)

Get the documentation for a config value.

  • return: documentation string
  • access: public
string getDocs (string $key)
  • string $key: config key
getGroup (line 882)

Get the parameter group for a config key.

  • return: parameter group
  • access: public
string getGroup (string $key)
  • string $key: config key
getGroupKeys (line 923)

Get the list of the parameters in a group.

  • return: list of parameters in $group
  • access: public
array getGroupKeys (string $group)
  • string $group: parameter group
getGroups (line 901)

Get the list of parameter groups.

  • return: list of parameter groups
  • access: public
array getGroups ()
getKeys (line 975)

Get all the current config keys.

  • return: simple array of config keys
  • access: public
array getKeys ()
getLayers (line 1155)

Returns the layers defined (except the 'default' one)

  • return: of the defined layers
array getLayers ()
getPrompt (line 862)

Get the short documentation for a config value.

  • return: short documentation string
  • access: public
string getPrompt (string $key)
  • string $key: config key
getSetValues (line 949)

Get the list of allowed set values for a config value. Returns NULL for config values that are not sets.

  • return: enumerated array of set values, or NULL if the config key is unknown or not a set
  • access: public
array getSetValues (string $key)
  • string $key: config key
getType (line 821)

Get the type of a config value.

  • return: type, one of "string", "integer", "file", "directory", "set" or "password".
  • access: public
string getType (string $key)
  • string $key: config key
isDefaulted (line 1102)

Tells whether a config value has a system-defined value.

  • deprecated:
  • access: public
bool isDefaulted (string $key)
  • string $key: config key
isDefined (line 1120)

Tells whether a given key exists as a config value.

  • return: whether <config key> exists in this object
  • access: public
bool isDefined (string $key)
  • string $key: config key
isDefinedLayer (line 1142)

Tells whether a given config layer exists.

  • return: whether <config layer> exists in this object
  • access: public
bool isDefinedLayer (string $layer)
  • string $layer: config layer
mergeConfigFile (line 518)

Merges data into a config layer from a file. Does the same thing as readConfigFile, except it does not replace all existing values in the config layer.

  • return: TRUE on success or a PEAR error on failure
bool mergeConfigFile (string $file, [bool $override = true], [string $layer = 'user'])
  • string $file: file to read from
  • bool $override: (optional) whether to overwrite existing data (default TRUE)
  • string $layer: config layer to insert data into ('user' or 'system')
readConfigFile (line 481)

Reads configuration data from a file. All existing values in the config layer are discarded and replaced with data from the file.

  • return: TRUE on success or a PEAR error on failure
  • access: public
bool readConfigFile ([string $file = null], [string $layer = 'user'])
  • string $file: (optional) file to read from, if NULL or not specified, the last-used file for the same layer (second param) is used
  • string $layer: (optional) config layer to insert data into ('user' or 'system')
remove (line 998)

Remove the a config key from a specific config layer.

  • return: TRUE on success, FALSE on failure
  • access: public
bool remove (string $key, [string $layer = 'user'])
  • string $key: config key
  • string $layer: (optional) config layer
removeLayer (line 1021)

Temporarily remove an entire config layer. USE WITH CARE!

  • return: TRUE on success, FALSE on failure
  • access: public
bool removeLayer (string $layer, string 1)
  • string 1: (optional) config layer
  • string $layer: config key
set (line 778)

Set a config value in a specific layer (defaults to 'user').

Enforces the types defined in the configuration_info array. An integer config variable will be cast to int, and a set config variable will be validated against its legal values.

  • return: TRUE on success, FALSE on failure
  • access: public
bool set (string $key, string $value, [string $layer = 'user'])
  • string $key: config key
  • string $value: config value
  • string $layer: (optional) config layer
singleton (line 452)

Static singleton method. If you want to keep only one instance of this class in use, this method will give you a reference to the last created PEAR_Config object if one exists, or create a new object.

  • return: existing or new PEAR_Config instance
  • see: PEAR_Config::PEAR_Config
  • access: public
object an &singleton ([string $user_file = ''], [string $system_file = ''])
  • string $user_file: (optional) file to read user-defined options from
  • string $system_file: (optional) file to read system-wide defaults from
store (line 1042)

Stores configuration data in a layer.

  • return: TRUE on success, or PEAR error on failure
  • access: public
bool store ([string $layer = 'user'], [mixed $data = null])
  • string $layer: config layer to store
toDefault (line 1060)

Unset the user-defined value of a config key, reverting the value to the system-defined one.

  • return: TRUE on success, FALSE on failure
  • access: public
bool toDefault (string $key)
  • string $key: config key
writeConfigFile (line 557)

Writes data into a config layer from a file.

  • return: TRUE on success or a PEAR error on failure
bool writeConfigFile ([string $file = null], [bool $layer = 'user'], [string $data = null])
  • string $file: file to read from
  • bool $layer: (optional) whether to overwrite existing data (default TRUE)
  • string $data: config layer to insert data into ('user' or 'system')
_decodeInput (line 708)

Decodes/unscrambles configuration data after reading from files.

  • return: TRUE on success
  • see: PEAR_Config::_encodeOutput
  • access: private
bool _decodeInput (array &$data)
  • array &$data: (reference) array to encode values in
_encodeOutput (line 671)

Encodes/scrambles configuration data before writing to files.

Currently, 'password' values will be base64-encoded as to avoid that people spot cleartext passwords by accident.

  • return: TRUE on success
  • access: private
bool _encodeOutput (array &$data)
  • array &$data: (reference) array to encode values in
_readConfigDataFrom (line 607)

Reads configuration data from a file and returns the parsed data in an array.

  • return: configuration data or a PEAR error on failure
  • access: private
array _readConfigDataFrom (string $file)
  • string $file: file to read from

Documentation generated on Fri, 24 Dec 2004 13:01:48 +0000 by phpDocumentor 1.3.0RC3