amanangira/php-config-manager

This library allows developers to implement different formats of file based configurations.

v1.3 2019-03-28 09:48 UTC

This package is auto-updated.

Last update: 2024-05-28 00:44:52 UTC


README

This library allows developers to use file based configurations in easy, organized and syntax friendly way. The library has been built keeping ease and minimal effort for developer in mind. It currently supports only two types i.e. JSON and PHP arrays. The base classes are easily extendible for further file type supports.

Installation

Composer

composer require amanangira/php-config-manager

Git

git clone https://github.com/amanangira/php-config-manager.git

Usage

Initializing

Php Array based configuration manager

use AmanAngira\ConfigManager\PhpArray\Manager;

$path = __DIR__ . '/config'; //Directory where the library expects the configuration files
$manager = new Manager($path); //Initializing object with the configurations path

JSON based configuration manager

use AmanAngira\ConfigManager\Json\Manager;

$path = __DIR__ . '/config'; //Directory where the library expects the configuration files
$manager = new Manager($path); //Initializing object with the configurations path

Accessing Configuration Value

$value = $manager->get('foo.var'); //use file name only (without extension) followed by full stop to access child values
if( $value === Manager::NOT_FOUND_FLAG ) //library flag if a value is not defined 
  echo "Value not defined";
else
  echo $value;

To Do

  • Implement cache based configuration
  • Enable modifying config values in current request scope