carry0987/config
Composer 安装命令:
composer require carry0987/config
包简介
A library for easily manipulating config of php program
README 文档
README
A library for easily manipulating config of php program
Overview
PHP-Config is a versatile library designed to simplify the manipulation and management of configurations within PHP applications. Whether it's handling configurations stored in a database, processing configurations for runtime use, or integrating with caching systems like Redis, PHP-Config streamlines your workflow.
Features
- Easy retrieval and updating of configuration settings.
- Support for fetching configurations from a database using PDO.
- Optional integration with Redis for caching configuration values.
- Customizable table name for configurations stored in the database.
- Robust error handling through custom exceptions.
- Type-safe operations with modern PHP type declarations.
Requirements
- PHP 7.4 or higher
- PDO extension for database interaction
- Optional: Redis server and PHP extension for Redis, if caching is desired
Installation
To integrate PHP-Config into your project, you can clone this repository and include it directly, or use Composer to manage the dependency.
To install using Composer:
composer require carry0987/config
Usage
Initialization
Below is an example of how to initialize the Config class with a PDO connection:
use carry0987\Config\Config; use carry0987\Redis\RedisTool; // Assuming $pdo is an instance of PDO $config = new Config($pdo); // Optionally, you can set a custom table name for the configuration. $config->setTableName('your_custom_config_table');
Redis Integration (Optional)
If you have Redis set up and would like to utilize it for configuration caching:
// Assuming $redis is an instance of RedisTool $config->setRedis($redis);
Adding a Configuration Setting
// To add a new configuration setting: $result = $config->addConfig('site_name', 'My Awesome Website');
Retrieving a Configuration Setting
// To fetch a configuration value by its key: $siteName = $config->getConfig('site_name', true);
Updating a Configuration Setting
// To update an existing configuration setting: $result = $config->updateConfig('site_name', 'My Even More Awesome Website');
Contributing
Contributions to PHP-Config are welcome. Please feel free to fork the repository and submit pull requests.
License
PHP-Config is released under the MIT License. See the bundled LICENSE file for details.
carry0987/config 适用场景与选型建议
carry0987/config 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 57 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 01 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 carry0987/config 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 carry0987/config 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 57
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-01-29