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.
composer require amanangira/php-config-manager
git clone https://github.com/amanangira/php-config-manager.git
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
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
$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;
- Implement cache based configuration
- Enable modifying config values in current request scope