PHP Classes

mezon PHP Configuration Options: Manipulate configuration options store in arrays

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


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: 185054 in Russian Federation Russian Federation
Week rank: 195 Up11 in Russian Federation Russian Federation Up
Innovation award
Innovation award
Nominee: 13x


Conf Build Status codecov


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

// or the same
$Value = get_config_value( array( 'res' , 'images' , 'favicon' ) , '' );

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  
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 Doc. Documentation

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

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:11,224
This week:206Up