2017 © Pedro Peláez
 

library lib-config

Configuration access helper and environment manager

image

openlss/lib-config

Configuration access helper and environment manager

  • Tuesday, September 10, 2013
  • by nullivex
  • Repository
  • 1 Watchers
  • 0 Stars
  • 23,081 Installations
  • PHP
  • 8 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 17 Versions
  • 4 % Grown

The README.md

openlss/lib-config

Configuration access helper and environment manager, (*1)

Usage


//build config $config = array(); $config['test1'] = 'test'; $config['test2']['sec'] = 'test'; $config['test3']['sec'] = 'test2'; //load config Config::setConfig($config); unset($config); //set an additional Config::set('test2.newsec',null,'testvalue'); //get options $test = Config::get('test1'); $test2 = Config::get('test2.sec'); $test3 = Config::get('test2.newsec'); //get merged $db = Config::getMerged('sec'); //will return test2

Singleton

Config operates with an internal singleton even though all the methods are static., (*2)

To retrieve the singleton use the following, (*3)

//use the clone keyword to actually copy the object (this is optional)
$inst = clone Config::_get();

//load up a new temporary config
Config::setConfig($newconfig);

//restore the old config
Config::$inst = clone $inst; unset($inst);

Reference

(object) _get()

Returns the current singleton (will create one if it doesnt exist), (*4)

(void) setConfig($config)

Will set the passed array to the main config This will merge with the existing config, (*5)

(void) resetConfig($config)

Resets the internal config registry, (*6)

(void) dumpConfig($config)

var_dumps the internal config Note: use output buffers to capture this, (*7)

(void) setDefaults($config)

Made to be used by packages will set the passed config below the internal config Example:, (*8)

self::_get()->config = array_merge($config,self::_get()->config);

This allows userspace overrides to remain in affect regardless of registration time., (*9)

(mixed) set($sec,$name,$value)

Sets a value in the config * $sec config section (can be an MDA key) NULL for none * $name config name (can be an MDA key) NULL for none * $value Value to be set Returns the value to be set, (*10)

(bool) exists($sec,$name=null)

Check if a value exists * $sec config section (can be an MDA key) NULL for none * $name config name (can be an MDA key) NULL for none, (*11)

(mixed) get($sec=null,$name=null)

Get a value from the confi structure * $sec config section (can be an MDA key) NULL for none * $name config name (can be an MDA key) NULL for none, (*12)

(mixed) getMerged($sec,$name=null)

Get a merged value from the config tree Consider the following config structure, (*13)

//full tree
$config['db']['driver'] = 'mysql';
$config['admin']['db']['driver'] = 'sqlite3';

Config::setConfig($config);
$val = Config::getMerged('admin','db.driver'); //returns 'sqllite'

//shorthand tree
$config['db']['driver'] = 'mysql';

Config::setConfig($config);
$val = Config::getMerged('admin','db.driver'); //returns 'mysql'

The idea is to retrieve a section from a subroot and gracefully look upstream. * $sec config section (can be an MDA key) NULL for none * $name config name (can be an MDA key) NULL for none, (*14)

The Versions

10/09 2013

dev-master

9999999-dev http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

configuration config config override system configuration

10/09 2013

dev-0.0.x-dev

dev-0.0.x-dev http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

configuration config config override system configuration

10/09 2013

0.0.15

0.0.15.0 http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

configuration config config override system configuration

09/04 2013

0.0.14

0.0.14.0 http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

configuration config config override system configuration

07/04 2013

0.0.10

0.0.10.0 http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

configuration config config override system configuration

07/04 2013

0.0.11

0.0.11.0 http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

configuration config config override system configuration

07/04 2013

0.0.12

0.0.12.0 http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

configuration config config override system configuration

07/04 2013

0.0.13

0.0.13.0 http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

configuration config config override system configuration

07/04 2013

0.0.9

0.0.9.0 http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

configuration config config override system configuration

03/04 2013

0.0.8

0.0.8.0 http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

configuration config config override system configuration

03/04 2013

0.0.6

0.0.6.0 http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

configuration config config override system configuration

03/04 2013

0.0.7

0.0.7.0 http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

configuration config config override system configuration

27/03 2013

0.0.5

0.0.5.0 http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

configuration config config override system configuration

26/03 2013

0.0.4

0.0.4.0 http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPL-3.0+

The Requires

 

The Development Requires

configuration config config override system configuration

23/03 2013

0.0.3

0.0.3.0 http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPL-3.0+

The Requires

 

configuration config config override system configuration

23/03 2013

0.0.2

0.0.2.0 http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPLv2

The Requires

 

configuration config config override system configuration

23/03 2013

0.0.1

0.0.1.0 http://openlss.org

Configuration access helper and environment manager

  Sources   Download

LGPLv2

The Requires

 

configuration config config override system configuration