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    
Last Updated Ratings Unique User Downloads Download Rankings
2020-11-18 (15 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 11 This week: 1All time: 10,130 This week: 195Up
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: 33 packages by
Country: Russian Federation Russian Federation
Age: ???
All time rank: 261375 in Russian Federation Russian Federation
Week rank: 1 Up
Innovation award
Innovation award
Nominee: 4x

 

Details

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  
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  /  Tests  
File Role Description
  Plain text file ConfUnitTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:11
This week:1
All time:10,130
This week:195Up

For more information send a message to info at phpclasses dot org.