PHP Classes

mezon PHP Configuration Options: Manipulate configuration options store in arrays

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 20 All time: 11,286 This week: 206Up
Version License PHP version Categories
mezon-conf 1.0MIT/X Consortium ...5PHP 5, Configuration, Parsers
Description 

Author

This class can manipulate configuration options store in arrays.

It contains an array that stores configuration values that can be manipulated by the class functions it several ways.

The class functions can take as parameter value path of a configuration value to be manipulated.

Currently those class functions can get, set, add, delete and check if it exist certain configuration values.

The class also comes with global functions to simplify calling the class functions that manipulate the configurations values.

Picture of Alexey Dodonov
  Performance   Level  
Name: Alexey Dodonov <contact>
Classes: 58 packages by
Country: Russian Federation Russian Federation
Age: ???
All time rank: 184954 in Russian Federation Russian Federation
Week rank: 164 Up10 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 13x

Documentation

Conf Build Status codecov

Configuration

Mezon has it's own config. It can be accesed with a set of functions, wich are described below.

Getting access to the key in config can be done with get_config_value( $Route , $DefaultValue = false ) function. It returns config value with route $Route and return $DefaultValue if this key was not found. For example:

$Value = get_config_value( 'res/images/favicon' , 'http://yoursite.com/res/images/favicon.ico' );

// or the same
$Value = get_config_value( array( 'res' , 'images' , 'favicon' ) , 'http://yoursite.com/res/images/favicon.ico' );

Setting values for the config key can be done by calling set_config_value( $Route , $Value ) or add_config_value( $Route , $Value ) function. The main difference between these two functions is that the first one sets scalar key, and the second one adds element to the array in config. Here is small example:

set_config_value( 'res/value' , 'Value!' );
var_dump( get_config_value( 'res/value' ) ); // displays 'Value!' string

add_config_value( 'res/value' , 'Value 1!' );
add_config_value( 'res/value' , 'Value 2!' );
var_dump( get_config_value( 'res/value' ) ); // displays array( [0] => 'Value 1!' , [1] => 'Value 2!' ) array

If you are not shure that the key exists, then you can check it:

set_config_value( 'res/value' , 'Value!' );

var_dump( config_key_exists( 'res' ) ); // true
var_dump( config_key_exists( 'res2' ) ); // false
var_dump( config_key_exists( 'res/value' ) ); // true

You can also able to delete config key

set_config_value( 'res/value' , 'Value!' );
delete_config_value( 'res/value' );
var_dump( config_key_exists( 'res/value' ) ); // false
var_dump( config_key_exists( 'res' ) ); // also false

That's all you need to know about config read/write.


  Files folder image Files (6)  
File Role Description
Files folder imageTests (1 file)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Plain text file Conf.php Class Class source
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (6)  /  Tests  
File Role Description
  Plain text file ConfUnitTest.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:20
This week:0
All time:11,286
This week:206Up