Phly Documentation Phly
[ return to channel ] [ class tree: Phly ] [ index: Phly ] [ all elements ]

Class: Phly_Config

Source Location: /Phly_Config/Phly/Config.php

Class Phly_Config

Class Overview

Phly_Config: Configuration class

Phly_Config is a singleton configuration registry. You may load configurations from in-memory arrays, PHP files returning arrays, INI files, XML files, or any other adapter you define; configuration loading can be done at any time, and any changes will be recognized by any Phly_Config instance.

Configurations are loaded into Phly_Hash objects, allowing object oriented notation for retrieving and setting configuration properties.

Adapters shipped at this time include:

Examples:
  1. require_once 'Phly/Config.php';
  2. Phly_Config::load($array);
  3. $config = Phly_Config::getInstance();
  4.  
  5. $db_host = $config->db->host;
  6. $db_name = $config->db->name;
  7.  
  8. // load from INI file
  9. Phly_Config::load('config.ini', 'production');
  10. $db_prod_host = $config->production->db->host;
  11. $db_proc_name = $config->production->db->name;
  12.  
  13. // load from PHP file returning an array
  14. Phly_Config::load('config.php', 'dev');
  15. $db_dev_host = $config->dev->db->host;
  16.  
  17. // load from XML file
  18. Phly_Config::load('config.xml', 'qa');
  19. $db_qa_host = $config->qa->db->host;

Located in /Phly_Config/Phly/Config.php [line 80]



		
				Author(s):
		
		
		
Information Tags:
Version:  @release-version@
Copyright:  2006 - Present, Matthew Weier O'Phinney
[ Top ]
Property Summary
array   $_config   Configuration arrays

[ Top ]
Method Summary
void   clear()   Clear a namespace's settings
Phly_Config   getInstance()   Get singleton instance
void   load()   Load configuration into object
array   toArray()   Return all configuration options as an array
boolean   _isAssocArray()   Test if a value is an associative array
mixed   __get()   Overloading: retrieve property values
void   __set()   Overloading: set property values

[ Top ]
Properties
array   $_config = array() [line 88]

Configuration arrays

API Tags:
Static:  
Access:  protected


[ Top ]
Methods
clear  [line 275]

  void clear( string $namespace  )

Clear a namespace's settings

Parameters:
string   $namespace: 

API Tags:
Access:  public


[ Top ]
getInstance  [line 197]

  Phly_Config getInstance( )

Get singleton instance


API Tags:
Static:  
Access:  public


[ Top ]
load  [line 128]

  void load( array $source, [string $namespace = 'default']  )

Load configuration into object

Expects one required argument, $source. $source may be:

  • an array
  • a string
If $source is a string, load() expects it to end with '.adapter', the name of an adapter class from which to load a configuration array. $source is then passed to that adapter's load() method.

Parameters:
array   $source: 
string   $namespace:  Defaults to 'default'

API Tags:
Static:  
Access:  public

Information Tags:
Throws:  Phly_Config_Exception

[ Top ]
toArray  [line 257]

  array toArray( )

Return all configuration options as an array


API Tags:
Access:  public


[ Top ]
_isAssocArray  [line 181]

  boolean _isAssocArray( mixed $value  )

Test if a value is an associative array

Parameters:
mixed   $value: 

API Tags:
Static:  
Access:  public


[ Top ]
__get  [line 213]

  mixed __get( string $key  )

Overloading: retrieve property values

Parameters:
string   $key: 

API Tags:
Access:  public


[ Top ]
__set  [line 233]

  void __set( string $key, mixed $value  )

Overloading: set property values

Parameters:
string   $key: 
mixed   $value: 

API Tags:
Access:  public


[ Top ]