23/10
2017
Wallogit.com
2017 © Pedro Peláez
Read .json files as config.
Read
.jsonfiles as config., (*1)
$ composer require try/json-config
<?php
require_once '/path/to/autoload.php';
use function TryPhp\jsonConfig;
$config = jsonConfig(__DIR__ . '/some.json');
$somethingNested = $config->get('first_lvl.second_lvl.value');
jsonConfig($path)Function to load an return a .json file as accessable config. (Will return a class@anonymous object), (*3)
| Argument | Type | Description |
|---|---|---|
| $path | string |
Path to the .json file that should be read as a config. |
API description of the returned object., (*4)
| Method | Arguments | Description |
|---|---|---|
| get($identifier, $seperator) |
$identifier (string)(required), $seperator (string)(default: .) |
Method to retrieve nested config entries more easily. |
| Property | Type | Description |
|---|---|---|
| $config | \stdClass |
Property that contains the config as loaded by json_decode. |
GPL-2.0 © Willi Eßer, (*5)