dflydev/dot-access-configuration
Composer 安装命令:
composer require dflydev/dot-access-configuration
包简介
Given a deep data structure representing a configuration, access configuration by dot notation.
关键字:
README 文档
README
Given a deep data structure representing a configuration, access configuration by dot notation.
This library combines dflydev/dot-access-data and dflydev/placeholder-resolver to provide a complete configuration solution.
Requirements
- PHP (5.3+)
- dflydev/dot-access-data (^3)
- dflydev/placeholder-resolver (1.x)
- symfony/yaml (>2,<2.2) (suggested)
Usage
Generally one will use an implementation of ConfigurationBuilderInterface
to build ConfigurationInterface instances. For example, to build a Configuration
out of a YAML file, one would use the YamlFileConfigurationBuilder:
use Dflydev\DotAccessConfiguration\YamlFileConfigurationBuilder; $configurationBuilder = new YamlFileConfigurationBuilder('config/config.yml'); $configuration = $configurationBuilder->build();
Once created, the Configuration instance behaves similarly to a Data instance from dflydev/dot-access-data.
$configuration->set('a.b.c', 'ABC'); $configuration->get('a.b.c'); $configuration->set('a.b.e', array('A', 'B', 'C')); $configuration->append('a.b.e', 'D');
Custom Configurations
Configuration Builders use Configuration Factories and Placeholder Resolver Factories behind the scenes in order to build a working configuration.
Under normal circumstances one should not need to do anything with the
Placeholder Resolver Factory. However, one may wish to extend the
default Configuration class or use an entirely different implementation
altogether.
In order to build instances of custom ConfigurationInterface implementations
with the standard builders, one would need to implement
ConfigurationFactoryInterface and inject it into any
ConfigurationBuilderInterface.
If a Configuration is declared as follows:
namespace MyProject; use Dflydev\DotAccessConfiguration\Configuration; class MyConf extends Configuration { public function someSpecialMethod() { // Whatever you want here. } }
Create the following factory:
namespace MyProject; use Dflydev\DotAccessConfiguration\ConfigurationFactoryInterface; class MyConfFactory implements ConfigurationFactoryInterface { /** * {@inheritdocs} */ public function create() { return new MyConf; } }
To use the factory with any builder, inject it as follows:
use Dflydev\DotAccessConfiguration\YamlFileConfigurationBuilder; use MyProject\MyConfFactory; $configurationBuilder = new YamlFileConfigurationBuilder('config/config.yml'); // Inject your custom Configuration Factory $configurationBuilder->setConfigurationFactory(new MyConfFactory); // Will now build instances of MyConfFactory instead of // the standard Configuration implementation. $configuration = $configurationBuilder->build();
License
This library is licensed under the New BSD License - see the LICENSE file for details.
Community
If you have questions or want to help out, join us in the #dflydev channel on irc.freenode.net.
dflydev/dot-access-configuration 适用场景与选型建议
dflydev/dot-access-configuration 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 14.53M 次下载、GitHub Stars 达 134, 最近一次更新时间为 2012 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「configuration」 「config」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dflydev/dot-access-configuration 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dflydev/dot-access-configuration 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dflydev/dot-access-configuration 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Configuration component
A Zend Framework module to quickly and easily set PHP settings.
Utils to load, parse and work with configuration on Mezzio projects
Server environment detection based on config array-file
Single and multi-dimensional parameter bag with dot-path access for PHP.
Trait to support creating complex nested class structures from JSON/YAML objects.
统计信息
- 总下载量: 14.53M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 134
- 点击次数: 28
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-04-24