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

Class: PEAR_Config

Source Location: /PEAR-1.10.0dev2/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):

Version:

  • Release: 1.10.0dev2

Copyright:

  • 1997-2009 The Authors

Variables

Methods


Inherited Variables

Inherited Methods

Class: PEAR

PEAR::__construct()
Constructor. Registers this object in $_PEAR_destructor_object_list for destructor emulation if a destructor object exists.
PEAR::PEAR()
Only here for backwards compatibility.
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 independent PHP extension load. Remember to take care on the correct extension name for case sensitive OSes.
PEAR::popExpect()
This method pops one element off the expected error codes stack.
PEAR::registerShutdownFunc()
Use this function to register a shutdown method for static classes.
PEAR::staticPopErrorHandling()
PEAR::staticPushErrorHandling()
PEAR::_PEAR()
Destructor (the emulated type of...). Does nothing right now, but is included for forward compatibility, so subclass destructors should always call it.
PEAR::_popErrorHandling()
Pop the last error handler used
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::_setErrorHandling()
Sets how errors generated by this object should be handled.
PEAR::_throwError()
Simpler form of raiseError with fewer options. In most cases message, code and userinfo are enough.
PEAR::__call()
PEAR::__callStatic()

Class Details

[line 271]
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 297]

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(
        // Channels/Internet Access
        'default_channel' => array(
            'type' => 'string',
            'default' => PEAR_CONFIG_DEFAULT_CHANNEL,
            'doc' => 'the default channel to use for all non explicit commands',
            'prompt' => 'Default Channel',
            'group' => 'Internet Access',
            ),'preferred_mirror'=>array('type'=>'string','default'=>PEAR_CONFIG_DEFAULT_CHANNEL,'doc'=>'the default server or mirror to use for channel actions','prompt'=>'Default Channel Mirror','group'=>'Internet Access',),'remote_config'=>array('type'=>'password','default'=>'','doc'=>'ftp url of remote configuration file to use for synchronized install','prompt'=>'Remote Configuration File','group'=>'Internet Access',),'auto_discover'=>array('type'=>'integer','default'=>0,'doc'=>'whether to automatically discover new channels','prompt'=>'Auto-discover new Channels','group'=>'Internet Access',),// Internet Access
'master_server'=>array('type'=>'string','default'=>'pear.php.net','doc'=>'name of the main PEAR server [NOT USED IN THIS VERSION]','prompt'=>'PEAR server [DEPRECATED]','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)',),'cfg_dir'=>array('type'=>'directory','default'=>PEAR_CONFIG_DEFAULT_CFG_DIR,'doc'=>'directory where modifiable configuration files are installed','prompt'=>'PEAR configuration file directory','group'=>'File Locations (Advanced)',),'www_dir'=>array('type'=>'directory','default'=>PEAR_CONFIG_DEFAULT_WWW_DIR,'doc'=>'directory where www frontend files (html/js) are installed','prompt'=>'PEAR www files directory','group'=>'File Locations (Advanced)',),'man_dir'=>array('type'=>'directory','default'=>PEAR_CONFIG_DEFAULT_MAN_DIR,'doc'=>'directory where unix manual pages are installed','prompt'=>'Systems manpage files 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 web service cache','prompt'=>'PEAR Installer cache directory','group'=>'File Locations (Advanced)',),'temp_dir'=>array('type'=>'directory','default'=>PEAR_CONFIG_DEFAULT_TEMP_DIR,'doc'=>'directory which is used for all temp files','prompt'=>'PEAR Installer temp directory','group'=>'File Locations (Advanced)',),'download_dir'=>array('type'=>'directory','default'=>PEAR_CONFIG_DEFAULT_DOWNLOAD_DIR,'doc'=>'directory which is used for all downloaded files','prompt'=>'PEAR Installer download 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)',),'php_prefix'=>array('type'=>'string','default'=>'','doc'=>'--program-prefix for php_bin\'s ./configure, used for pecl installs','prompt'=>'--program-prefix passed to PHP\'s ./configure','group'=>'File Locations (Advanced)',),'php_suffix'=>array('type'=>'string','default'=>'','doc'=>'--program-suffix for php_bin\'s ./configure, used for pecl installs','prompt'=>'--program-suffix passed to PHP\'s ./configure','group'=>'File Locations (Advanced)',),'php_ini'=>array('type'=>'file','default'=>'','doc'=>'location of php.ini in which to enable PECL extensions on install','prompt'=>'php.ini location','group'=>'File Locations (Advanced)',),'metadata_dir'=>array('type'=>'directory','default'=>PEAR_CONFIG_DEFAULT_METADATA_DIR,'doc'=>'directory where metadata files are installed (registry, filemap, channels, ...)','prompt'=>'PEAR metadata directory','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'=>'directory','default'=>PEAR_CONFIG_DEFAULT_SIG_KEYDIR,'doc'=>'directory where signature keys are located','prompt'=>'Signature Key Directory','group'=>'Maintainers',),// __channels is reserved - used for channel-specific configuration
)

[line 366]

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 278]

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

Type:   array


[ Top ]

$layers = array()

[line 283]


Type:   mixed


[ Top ]



Method Detail

__construct (Constructor)   [line 627]

PEAR_Config __construct( [string $user_file = ''], [string $system_file = ''], [bool $ftp_file = false], [bool $strict = true])

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

Overrides PEAR::__construct() (Constructor. Registers this object in $_PEAR_destructor_object_list for destructor emulation if a destructor object exists.)

Parameters:

string   $user_file   —  file to read user-defined options from
string   $system_file   —  file to read system-wide defaults from
bool   $ftp_file   —  determines whether a registry object "follows" the value of php_dir (is automatically created and moved when php_dir is changed)
bool   $strict   —  if true, fails if configuration files cannot be loaded

[ Top ]

apiVersion   [line 2005]

void apiVersion( )


[ Top ]

arrayMergeRecursive   [line 963]

array arrayMergeRecursive( array $arr2, array $arr1)

  • Access: public

Parameters:

array   $arr2   — 
array   $arr1   — 

[ Top ]

definedBy   [line 1937]

string|array definedBy( string $key, [boolean $returnchannel = false])

Tells what config layer that gets to define a key.
  • Return:

    the config layer, or an empty string if not found.

    if $returnchannel, the return is an array array('layer' => layername, 'channel' => channelname), or an empty string if not found

  • Access: public

Parameters:

string   $key   —  config key
boolean   $returnchannel   —  return the defining channel

[ Top ]

deleteChannel   [line 890]

void deleteChannel( $channel)


Parameters:

   $channel   — 

[ Top ]

get   [line 1340]

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

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   — 
   $channel   — 

[ Top ]

getConfFile   [line 1113]

void getConfFile( string $layer)

Gets the file used for storing the config for a layer

Parameters:

string   $layer   —  'user' or 'system'

[ Top ]

getDefaultChannel   [line 1303]

string|false getDefaultChannel( [string $layer = null])

Retrieve the default channel.

On startup, channels are not initialized, so if the default channel is not pear.php.net, then initialize the config.


Parameters:

string   $layer   —  registry layer

[ Top ]

getDefaultConfigFiles   [line 693]

void getDefaultConfigFiles( )

Return the default locations of user and system configuration files
  • Access: public

[ Top ]

getDocs   [line 1723]

string getDocs( string $key)

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

Parameters:

string   $key   —  config key

[ Top ]

getFTP   [line 2079]

PEAR_FTP|false &getFTP( )

The ftp server is set in readFTPConfigFile(). It exists only if a

remote configuration file has been specified


[ Top ]

getGroup   [line 1759]

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 1795]

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 1776]

array getGroups( )

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

[ Top ]

getKeys   [line 1843]

array getKeys( )

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

[ Top ]

getLayers   [line 1998]

array getLayers( )

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

[ Top ]

getPrompt   [line 1741]

string getPrompt( string $key)

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

Parameters:

string   $key   —  config key

[ Top ]

getRegistry   [line 2013]

PEAR_Registry &getRegistry( [ $use = null])


Parameters:

   $use   — 

[ Top ]

getREST   [line 2063]

PEAR_REST &getREST( $version, [ $options = array()])


Parameters:

   $version   — 
   $options   — 

[ Top ]

getSetValues   [line 1818]

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 1706]

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 ]

isDefined   [line 1969]

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 1988]

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 914]

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

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   —  whether to overwrite existing data (default TRUE)
string   $layer   —  config layer to insert data into ('user' or 'system')
string   $strict   —  if true, errors are returned if file opening fails

[ Top ]

noRegistry   [line 2055]

void noRegistry( )


[ Top ]

readConfigFile   [line 761]

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

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

Parameters:

string   $file   —  file to read from, if NULL or not specified, the last-used file for the same layer (second param) is used
string   $layer   —  config layer to insert data into ('user' or 'system')
   $strict   — 

[ Top ]

readFTPConfigFile   [line 803]

true|PEAR_Error readFTPConfigFile( string $path)


Parameters:

string   $path   —  url to the remote config file, like ftp://www.example.com/pear/config.ini

[ Top ]

remove   [line 1871]

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

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
string   $channel   —  (optional) channel (defaults to default channel)

[ Top ]

removeLayer   [line 1901]

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 1500]

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

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

Parameters:

string   $key   —  config key
string   $value   —  config value
string   $layer   —  (optional) config layer
string   $channel   —  channel to set this value for, or null for global value

[ Top ]

setChannels   [line 1663]

bool setChannels( array $channels, [bool $merge = false])

Set the list of channels.

This should be set via a call to PEAR_Registry::listChannels()

  • Return: success of operation

Parameters:

array   $channels   — 
bool   $merge   — 

[ Top ]

setInstallRoot   [line 2110]

void setInstallRoot( string|false $root)


Parameters:

string|false   $root   —  installation directory to prepend to all _dir variables, or false to disable

[ Top ]

setRegistry   [line 2037]

bool setRegistry( PEAR_Registry &$reg, [ $layer = 'user'])

This is to allow customization like the use of installroot

Parameters:

PEAR_Registry   &$reg   — 
   $layer   — 

[ Top ]

singleton   [line 722]

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

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
   $strict   — 

[ Top ]

store   [line 1919]

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 ]

validConfiguration   [line 743]

bool validConfiguration( )

Determine whether any configuration files have been detected, and whether a registry object can be retrieved from this configuration.
  • Since: PEAR 1.4.0a1

[ Top ]

writeConfigFile   [line 995]

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

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

Parameters:

string|null   $file   —  file to read from, or null for default
string   $layer   —  config layer to insert data into ('user' or 'system')
string|null   $data   —  data to write to config file or null for internal data [DEPRECATED]

[ Top ]


Documentation generated on Fri, 31 Jul 2015 09:30:21 +0000 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.