th3shadowbroker/json-configuration

一个基本的json-configuration。

v1.0.0 2019-04-23 21:22 UTC

This package is auto-updated.

Last update: 2024-09-10 06:16:36 UTC


README

这个库(实际上它只是一个文件 xD)包含了一个基于json的基本配置处理器。

Composer

php-json-configuration 可在 Packagist 上找到

composer require th3shadowbroker/json-configuration

示例

//Use class.
use github\th3shadowbroker\json_config\JsonConfiguration;

//Create a new config
$config = new JsonConfiguration(__DIR__.'/somefile.json');

//Set a default value.
$config->setDefault('something', 'anything');

//Set multiple defaults at once.
$config->setDefaults( ['another' => 'value'] );

//Set the value of a nested key.
$config->set('sonethingnested.nest', 'a nested value');

//Save the configuration.
$config->save();

//or save it to another location
$config->save(__DIR__.'/someotherfile.json');

echo $config->get('somethingnested.nest');