sam-burns / config-tree
1.0.0
2017-01-19 13:25 UTC
Requires
- php: ^7.1
- symfony/yaml: ^2.7|^3.0
Requires (Dev)
- behat/behat: ^3.3
- phpspec/phpspec: ^3.2
- phpunit/phpunit: ^5.7
This package is auto-updated.
Last update: 2024-11-24 04:42:26 UTC
README
Config Tree
Description
A library for reading config files of various formats, and representing them as config tree objects.
Example of usage
config.json
file:
{ "parameters": { "mysql": { "user": "dbuser" } } }
$configBuilder = new \ConfigTree\Builder\ConfigTreeBuilder(); $configBuilder->addSettingsFromPath('/path/config.json'); $config = $configBuilder->buildConfigTreeAndReset(); $mysqlUsername = $config->getSettingFromPath('parameters/mysql/user'); // $mysqlUsername === "dbuser"
Or, do stuff like this:
$dbConfig = $config->getSubtreeFromPath('parameters/mysql');