thewunder/conphigure
Composer 安装命令:
composer require thewunder/conphigure
包简介
Framework Agnostic Configuration Library
README 文档
README
Conphigure is a framework agnostic library for reading and retrieving configuration. If your application has outgrown a single configuration file this library will be a good choice.
It can read configuration files in the following formats:
- php
- yaml
- json
- xml
- ini
- dotenv
Conphigure can also read entire directories containing configuration files.
Install
Via Composer
$ composer require thewunder/conphigure
Usage
If you have configuration in myfile.yml
smtp: host: smtp.mycompany.com port: 25
Read it in your php application like the following
$config = Conphigure::create(); //load configuration from a single file $config->read('/directory/myfile.yml'); //get a value $port = $config->get('smtp/port'); //add configuration from somewhere else (cache / database / etc) $arrayFromSomewhere = [ 'database' => [ 'host' => 'localhost' ] ]; $config->addConfiguration($arrayFromSomewhere); //you can also use it like an array $host = $config['database']['host']; $host = $config['database/host']; //throws an exception if a value is missing $value = $config->get('missing/key');
When reading a config directory Conphigure will (by default) organize the configuration in each file into a common root based on the file path.
For example, a directory /directory/config/ with:
- system.yml
- email.yml
- logging.yml
- subdirectory/something.yml
//read the directory $config->read('/directory/config/'); //get all configuration as an array $all = $config->all(); var_export($all); /* The result will be: [ 'system' => ['...'], //contents of system.yml 'email' => ['...'], //contents of email.yml 'logging' => ['...'], //contents of logging.yml 'subdirectory' => [ 'something' => ['...'], //contents of subdirectory/something.yml ] ]; */
This allows you to keep things organized, and keep each file very flat.
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
thewunder/conphigure 适用场景与选型建议
thewunder/conphigure 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20.75k 次下载、GitHub Stars 达 31, 最近一次更新时间为 2017 年 09 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「yaml」 「json」 「configuration」 「ini」 「config」 「Settings」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 thewunder/conphigure 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 thewunder/conphigure 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 thewunder/conphigure 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Configuration component
Kinikit - PHP Application development framework MVC component
ext-json wrapper with sane defaults
A package to cast json fields, each sub-keys is castable
Utils to load, parse and work with configuration on Mezzio projects
SUML for PHP
统计信息
- 总下载量: 20.75k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 31
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-09-22