symbiont/config
最新稳定版本:v1.2.9
Composer 安装命令:
composer require symbiont/config
包简介
Small Config Library
关键字:
README 文档
README
Simple config library.
This package is work in progress!
Requirements
- PHP
8.2
Installation
composer require symbiont/config
Usage
Using a general Config without a driver.
use Symbiont\Config\Config;
$config = new Config;
$config->set('key', 'value');
$config->get('key');
Using preconfigured ArrayConfig
// some-config.php
return [
'nothing' => null,
'some' => 'string',
'and' => [
'nested' => 'value'
],
'array' => [
'with',
'values'
]
]
{
"nothing": null,
"some": "string",
"and": {
"nested": "value"
},
"array": [
"with",
"values"
]
}
use Symbiont\Config\{Config, ArrayConfig, JsonConfig};
// as array
$config = new ArrayConfig('some-config.php');
// as json
$config = new JsonConfig('some-config.json');
// auto choose
$config = Config::from('some-config.json'); // returns JsonConfig object
$config->get('some') // `string`
$config->get('nothing', 'default-value') // `default-value`
$config->get('and->nested') // `value`
$config->set('and->nested', 'changed') // and->nested = `changed`
$config->set(['and', 'nested'], 'changed-again') // and->nested = `changed-again`
$config->add('array', 'added') // 'array' => ['with', 'values', 'changed']
$config->remove('array', 'values') // 'array' => ['with', 'changed']
$config->unset('some')
$config->save() // save changes to file
$config->store('new-file') // stores current config to new file
// @todo:
// $config->storeVersion() // stores a version of a config leaving the original untouched
// $config->loadVersion($version) // load a stored `$version` of the original config
Documentation
This documentation only documents the technical usage of this package with little to no text.
- Documentation: https://symbiont.gitlab.io/config
- Gitlab: https://gitlab.com/symbiont/config
Tests
composer test
License
统计信息
- 总下载量: 32
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-06-20