Skip to content

elephox-dev/configuration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elephox Configuration Module

This module is used by Elephox to load configuration files and provide easy access to their values. It was inspired by .NETs Configuration package.

Example

<?php

use Elephox\Configuration\ConfigurationManager;
use Elephox\Configuration\Json\JsonFileConfigurationSource;

$configurationManager = new ConfigurationManager();
$configurationManager->add(new JsonFileConfigurationSource('config.json'));
$configurationManager->add(new JsonFileConfigurationSource('config.local.json', optional: true));
$configurationRoot = $configurationManager->build();

echo $configurationRoot['database:host']; // 'localhost'
echo $configurationRoot['database:port']; // 3306
echo $configurationRoot['env']; // 'local'

config.json

{
    "env": "production",
    "database": {
        "host": "production-server",
        "port": 3306
    }
}

config.local.json

{
    "env": "local",
    "database": {
        "host": "localhost"
    }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages