Skip to content

Maintain clean file based configurations for your PHP project. Currently, the library supports two types JSON and PHP arrays.

License

Notifications You must be signed in to change notification settings

amanangira/php-config-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Configuration Manager

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

About

Maintain clean file based configurations for your PHP project. Currently, the library supports two types JSON and PHP arrays.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages