clagiordano/weblibs-configmanager
Composer 安装命令:
composer require clagiordano/weblibs-configmanager
包简介
weblibs-configmanager is a tool library for easily read and access to php config array file and direct read/write configuration file / object
README 文档
README
weblibs-configmanager
weblibs-configmanager is a tool library for easily read and access to php config array file and direct read/write configuration file / object.
Why use weblibs-configmanager ?
The purpose of this project is to propose a simple and lightweight library to manage php hierarchical configuration files.
Supported formats
This package supports config files in the following format:
| Format | Component | Since version | Description |
|---|---|---|---|
| Array | ConfigManager |
v0.1.0 |
Deprecated, legacy name for the php array reader, only for compatibility support |
| Array | ArrayConfigManager |
v1.2.0 |
A file that returns a php array, the original supported format |
| Yaml | YamlConfigManager |
v1.3.0 |
A file containing a valid YAML file |
| JSON | JsonConfigManager |
v1.4.0 |
A file containing a valid JSON file |
All the supported format are parsed and internally handled in the same way granting the same functionalities.
Installation
The recommended way to install weblibs-configmanager is through Composer.
composer require clagiordano/weblibs-configmanager
Usage examples (Array format)
Write a sample config file like this
<?php return array ( 'app' => 'app_name', 'db' => array ( 'host' => 'localhost', 'user' => 'sample_user', 'pass' => 'sample_pass', 'port' => 3306, ), 'other' => array ( 'multi' => array ( 'deep' => array ( 'nested' => 'config_value', ), ), ), );
Instance ConfigManager object
use clagiordano\weblibs\configmanager\ConfigManager; /** * Instance object to read argument file */ $config = new ConfigManager("configfile.php");
Check if a value exists into config file
/** * Check if a value exists into config file */ $value = $config->existValue('app');
Read a simple element from config file
/** * Read a simple element from config file */ $value = $config->getValue('app');
Access to a nested element from config
/** * Access to a nested element from config */ $nestedValue = $config->getValue('other.multi.deep.nested');
Change config value at runtime
/** * Change config value at runtime */ $this->config->setValue('other.multi.deep.nested', "SUPERNESTED");
Save config file with original name (OVERWRITE)
/** * Save config file with original name (OVERWRITE) */ $this->config->saveConfigFile();
Or save config file with a different name
/** * Save config file with original name (OVERWRITE) */ $this->config->saveConfigFile('/new/file/name/or/path/test.php');
Optionally you can also reload config file from disk after save
/** * Optionally you can also reload config file from disk after save */ $this->config->saveConfigFile('/new/file/name/or/path/test.php', true);
Load another configuration file without reinstance ConfigManager
/** * Load another configuration file without reinstance ConfigManager */ $this->config->loadConfig('another_config_file.php');
Legal
Copyright (C) Claudio Giordano claudio.giordano@autistici.org
clagiordano/weblibs-configmanager 适用场景与选型建议
clagiordano/weblibs-configmanager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.68M 次下载、GitHub Stars 达 16, 最近一次更新时间为 2016 年 08 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「configuration」 「manager」 「tool」 「clagiordano」 「weblibs」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 clagiordano/weblibs-configmanager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 clagiordano/weblibs-configmanager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 clagiordano/weblibs-configmanager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Configuration component
Backend Google Sign On for Magento 2
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
An app setting manager tool for laravel nova
Utils to load, parse and work with configuration on Mezzio projects
The Message Submission Agent Diagnostics tool (msadiag) facilitates testing the compatibility of third party message submission agents.
统计信息
- 总下载量: 3.68M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 17
- 点击次数: 31
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-or-later
- 更新时间: 2016-08-17