承接 symbiont/config 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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.

Tests

composer test

License

MIT license

统计信息

  • 总下载量: 32
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-20