nia / configuration
nia component for simple configuration file parsing.
This package's canonical repository appears to be gone and the package has been frozen as a result.
Requires
- php: >=7.0.0
- nia/collection-map-stringmap: *
This package is not auto-updated.
Last update: 2022-03-10 22:22:10 UTC
README
Unified reading of configurations.
Installation
Require this package with Composer.
composer require nia/configuration
Tests
To run the unit test use the following command:
$ cd /path/to/nia/component/
$ phpunit --bootstrap=vendor/autoload.php tests/
Sample: How to use it
The following sample shows you how to use this component for a string which contains a ini configuration. It uses the Nia\Configuration\Reader\Ini\IniStringConfiguration
class. If you want to read a ini file just use the Nia\Configuration\Reader\Ini\IniFileConfiguration
class.
There is also an implementation for json strings (Nia\Configuration\Reader\Json\JsonStringConfiguration
) and json files (Nia\Configuration\Reader\Json\JsonFileConfiguration
).
$content = <<<EOL [database] hostname=127.0.0.1 username=root password= port=1234 [environment] debug.mode=development debug.log=/var/log/application.log EOL; $configuration = new IniStringConfiguration($content); $hostname = $configuration->getSection('database')->get('hostname'); $debugLog = $configuration->getSection('environment')->get('debug.log');