定制 learningbird/lbconf 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

learningbird/lbconf

Composer 安装命令:

composer require learningbird/lbconf

包简介

Command line utility for reading and writing JSON configuration files

README 文档

README

Command line utility for reading and writing JSON configuration files

Installation

Install using composer:

$ composer require learningbird/lbconf

Setup

Create an .lbconf meta-configuration file in your project root:

Example:

{
    "read": [
        "configurations/default.json"
    ],
    "write": "configurations/override.json"
}

File paths are relative to the location of the meta-config file.

The files in BOTH the read and write sections are read and merged, and the file in the write section is written to when using the set command.

Dynamic Configuration

For more dynamic configurations, an .lbconf.php file can be used. This file must return an array that has the same format as the .lbconf JSON file.

return [
    'read'  => glob('configurations/default/*.json),
    'write' => 'configurations/override.json',
];

Usage

The general usage pattern is:

lbconf <action> <key> [value]

Where <action> is one of: -g|--get, -s|--set, -d|--del, -k|--keys. If only a key is provided, the action is assumed to be --get, and can be omitted. If both a key and a value are provided, the action is assumed to be --set, and can be omitted.

Example:

$ lbconf --get database.host # Outputs "localhost"
$ lbconf database.host # Identical to above

$ lbconf --set database.host 127.0.0.1 # Sets database.host to  "127.0.0.1"
$ lbconf database.host 127.0.0.1 # Identical to above

-g|--get

Retrieve configuration values.

$ lbconf --get database
$ lbconf -g database # Short form
$ lbconf database # Implicit "--get" form

# Output:
# {
#     "host": "localhost,
#     "port": 3306,
#     "username": "prod-user"
# }

Traverse objects by passing dot-separated keys:

$ lbconf --get database.host # Outputs "localhost"

-s|--set

Set configuration values. Values will be written to the file specified by the write key in the .lbconf meta-configuration file.

$ lbconf --set database.username dev-user
$ lbconf -s database.username dev-user # Short form
$ lbconf database.username dev-user # Implicit "--set" form

Types will be inferred, unless explicitly specified:

$ lbconf --set database.port 3306 # Value is cast to int
$ lbconf --set database.port 3306 --type string # Value remains as string

-d|--del

Delete overriding configuration values:

$ lbconf --del database.username
$ lbconf -d database.username # Short form

Note that the key must exist in the write file for the deletion to be permitted. There is no way to delete a key that only exists in the read file. The only alternative is to set it to null, or some such value.

-k|--keys

Retrieve configuration value keys:

$ lbconf --keys database
$ lbconf -k database # Short form

# Output:
# [
#     "host",
#     "port",
#     "username"
# ]

Misc

Keys beginning with dashes

By default, a command argument that begins with a - is interpreted as an option. To avoid this behaviour, if a configuration key begins with a -, you can use -- to separate the command options from the arguments:

$ lbconf --get -- --get # Outputs value for key "--get"
$ lbconf --set -- --key value # Sets the value for "--key" to "value"

learningbird/lbconf 适用场景与选型建议

learningbird/lbconf 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.9k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2016 年 07 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 learningbird/lbconf 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 learningbird/lbconf 我们能提供哪些服务?
定制开发 / 二次开发

基于 learningbird/lbconf 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-07-27