apidoc
[ class tree: apidoc ] [ index: apidoc ] [ all elements ]

Class: PEAR_Config

Source Location: /PEAR-1.3.5/PEAR/Config.php

Class Overview

PEAR
   |
   --PEAR_Config

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


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods

Class: PEAR

PEAR::PEAR()
Constructor. Registers this object in $_PEAR_destructor_object_list for destructor emulation if a destructor object exists.
PEAR::delExpect()
This method deletes all occurences of the specified element from the expected error codes stack.
PEAR::expectError()
This method is used to tell which errors you expect to get.
PEAR::getStaticProperty()
If you have a class that's mostly/entirely static, and you need static
PEAR::isError()
Tell whether a value is a PEAR error.
PEAR::loadExtension()
OS independant PHP extension load. Remember to take care on the correct extension name for case sensitive OSes.
PEAR::popErrorHandling()
Pop the last error handler used
PEAR::popExpect()
This method pops one element off the expected error codes stack.
PEAR::pushErrorHandling()
Push a new error handler on top of the error handler options stack. With this you can easily override the actual error handler for some code and restore it later with popErrorHandling.
PEAR::raiseError()
This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. If the $mode and $options parameters are not specified, the object's defaults are used.
PEAR::registerShutdownFunc()
Use this function to register a shutdown method for static classes.
PEAR::setErrorHandling()
Sets how errors generated by this object should be handled.
PEAR::staticPopErrorHandling()
PEAR::staticPushErrorHandling()
PEAR::throwError()
Simpler form of raiseError with fewer options. In most cases message, code and userinfo are enough.
PEAR::_PEAR()
Destructor (the emulated type of...). Does nothing right now, but is included for forward compatibility, so subclass destructors should always call it.

Class Details

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


[ Top ]


Class Variables

$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, ...)

Type:   array


[ Top ]

$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, ...)

Type:   array


[ Top ]

$files = array(
        'system' => '',
        'user' => '',
        )

[line 205]

Array of config files used.
  • Var: layer => config file

Type:   array


[ Top ]

$layers = array()

[line 210]


Type:   mixed


[ Top ]



Method Detail

PEAR_Config (Constructor)   [line 405]

PEAR_Config PEAR_Config( [string $user_file = ''], [string $system_file = ''])

Constructor.
  • See: PEAR_Config::singleton
  • Access: public

Parameters:

string   $user_file   —  (optional) file to read user-defined options from
string   $system_file   —  (optional) file to read system-wide defaults from

[ Top ]

definedBy   [line 1082]

string definedBy( string $key)

Tells what config layer that gets to define a key.
  • Return: the config layer, or an empty string if not found
  • Access: public

Parameters:

string   $key   —  config key

[ Top ]

get   [line 749]

mixed get( string $key, [ $layer = null])

Returns a configuration value, prioritizing layers as per the layers property.
  • Return: the config value, or NULL if not found
  • Access: public

Parameters:

string   $key   —  config key
   $layer   — 

[ Top ]

getConfFile   [line 656]

void getConfFile( string $layer)

Gets the file used for storing the config for a layer

Parameters:

string   $layer   —  'user' or 'system'

[ Top ]

getDocs   [line 846]

string getDocs( string $key)

Get the documentation for a config value.
  • Return: documentation string
  • Access: public

Parameters:

string   $key   —  config key

[ Top ]

getGroup   [line 886]

string getGroup( string $key)

Get the parameter group for a config key.
  • Return: parameter group
  • Access: public

Parameters:

string   $key   —  config key

[ Top ]

getGroupKeys   [line 927]

array getGroupKeys( string $group)

Get the list of the parameters in a group.
  • Return: list of parameters in $group
  • Access: public

Parameters:

string   $group   —  parameter group

[ Top ]

getGroups   [line 905]

array getGroups( )

Get the list of parameter groups.
  • Return: list of parameter groups
  • Access: public

[ Top ]

getKeys   [line 979]

array getKeys( )

Get all the current config keys.
  • Return: simple array of config keys
  • Access: public

[ Top ]

getLayers   [line 1159]

array getLayers( )

Returns the layers defined (except the 'default' one)
  • Return: of the defined layers

[ Top ]

getPrompt   [line 866]

string getPrompt( string $key)

Get the short documentation for a config value.
  • Return: short documentation string
  • Access: public

Parameters:

string   $key   —  config key

[ Top ]

getSetValues   [line 953]

array getSetValues( string $key)

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

Parameters:

string   $key   —  config key

[ Top ]

getType   [line 825]

string getType( string $key)

Get the type of a config value.
  • Return: type, one of "string", "integer", "file", "directory", "set" or "password".
  • Access: public

Parameters:

string   $key   —  config key

[ Top ]

isDefaulted   [line 1106]

bool isDefaulted( string $key)

Tells whether a config value has a system-defined value.
  • Deprecated:
  • Access: public

Parameters:

string   $key   —  config key

[ Top ]

isDefined   [line 1124]

bool isDefined( string $key)

Tells whether a given key exists as a config value.
  • Return: whether <config key> exists in this object
  • Access: public

Parameters:

string   $key   —  config key

[ Top ]

isDefinedLayer   [line 1146]

bool isDefinedLayer( string $layer)

Tells whether a given config layer exists.
  • Return: whether <config layer> exists in this object
  • Access: public

Parameters:

string   $layer   —  config layer

[ Top ]

mergeConfigFile   [line 522]

bool mergeConfigFile( string $file, [bool $override = true], [string $layer = 'user'])

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

Parameters:

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')

[ Top ]

readConfigFile   [line 485]

bool readConfigFile( [string $file = null], [string $layer = 'user'])

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

Parameters:

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')

[ Top ]

remove   [line 1002]

bool remove( string $key, [string $layer = 'user'])

Remove the a config key from a specific config layer.
  • Return: TRUE on success, FALSE on failure
  • Access: public

Parameters:

string   $key   —  config key
string   $layer   —  (optional) config layer

[ Top ]

removeLayer   [line 1025]

bool removeLayer( string $layer, string 1)

Temporarily remove an entire config layer. USE WITH CARE!
  • Return: TRUE on success, FALSE on failure
  • Access: public

Parameters:

string   1   —  (optional) config layer
string   $layer   —  config key

[ Top ]

set   [line 782]

bool set( string $key, string $value, [string $layer = 'user'])

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

Parameters:

string   $key   —  config key
string   $value   —  config value
string   $layer   —  (optional) config layer

[ Top ]

singleton   [line 456]

object an &singleton( [string $user_file = ''], [string $system_file = ''])

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

Parameters:

string   $user_file   —  (optional) file to read user-defined options from
string   $system_file   —  (optional) file to read system-wide defaults from

[ Top ]

store   [line 1046]

bool store( [string $layer = 'user'], [ $data = null])

Stores configuration data in a layer.
  • Return: TRUE on success, or PEAR error on failure
  • Access: public

Parameters:

string   $layer   —  config layer to store
   $data   — 

[ Top ]

toDefault   [line 1064]

bool toDefault( string $key)

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

Parameters:

string   $key   —  config key

[ Top ]

writeConfigFile   [line 561]

bool writeConfigFile( [string $file = null], [bool $layer = 'user'], [string $data = null])

Writes data into a config layer from a file.
  • Return: TRUE on success or a PEAR error on failure

Parameters:

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')

[ Top ]


Documentation generated on Mon, 11 Mar 2019 14:23:56 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.