effectra/config
Composer 安装命令:
composer require effectra/config
包简介
The Effectra Config package.
README 文档
README
The Effectra\Config library provides a set of classes and interfaces for managing and working with configuration settings in PHP applications.
Features
- Configuration file handling: Read and manipulate configuration settings stored in files.
- Driver configuration: Define and manage driver-related settings such as host, port, username, and password.
- Cookie configuration: Create and manage HTTP cookies with various attributes.
- Editor configuration: Parse and retrieve settings from EditorConfig files.
Installation
Install the library using Composer:
composer require effectra/config
Usage
- Include the necessary classes or interfaces in your PHP files:
use Effectra\Config\ConfigFile; use Effectra\Config\ConfigDriver; use Effectra\Config\ConfigCookie; use Effectra\Config\ConfigEditor;
- Use the provided classes to handle configuration settings based on your application's requirements.
Example 1: Reading and Manipulating Configuration Files
use Effectra\Config\ConfigFile; // Create a ConfigFile instance with the path to your configuration file $configFile = new ConfigFile('/path/to/config.ini'); // Read the configuration settings from the file $config = $configFile->read(); // Access specific sections and settings $databaseConfig = $configFile->getSection('database'); $host = $databaseConfig['host']; $username = $databaseConfig['username']; // Modify a setting and write the changes back to the file $config['app']['debug'] = true; $configFile->setFile('/path/to/config.ini')->write($config);
Example 2: Creating and Managing ConfigDriver
use Effectra\Config\ConfigDriver; // Create a ConfigDriver instance with initial settings $driver = new ConfigDriver('mysql', 'localhost', 3306, 'username', 'password'); // Get the current driver details $driverName = $driver->getDriver(); $host = $driver->getHost(); // Update the driver settings $driver = $driver->withHost('newhost')->withPort(8888); // Get the updated driver details $newHost = $driver->getHost(); $newPort = $driver->getPort();
Example 3: Creating and Modifying ConfigCookie
use Effectra\Config\ConfigCookie; // Create a ConfigCookie instance with initial attributes $cookie = new ConfigCookie('session', 'abc123', 3600, '/', 'example.com', true, true); // Get the cookie attributes $name = $cookie->getName(); $secure = $cookie->getSecure(); // Create a new cookie instance with updated attributes $newCookie = $cookie->withExpireOrOptions(7200)->withSecure(false); // Get the updated cookie attributes $newExpire = $newCookie->getExpireOrOptions(); $newSecure = $newCookie->getSecure();
Example 4: Parsing EditorConfig File
use Effectra\Config\ConfigEditor; // Create a ConfigEditor instance with the path to an EditorConfig file $editorConfig = new ConfigEditor('/path/to/.editorconfig'); // Get the root value from the EditorConfig file $root = $editorConfig->getRoot(); // Get the indent_size and end_of_line settings $indentSize = $editorConfig->getIndentSize(); $endOfLine = $editorConfig->getEndOfLine(); // Check if a charset setting is defined if ($editorConfig->hasSection('charset')) { $charsetSettings = $editorConfig->getSection('charset'); // Process the charset settings } else { // Handle the case when charset settings are not present }
Feel free to adjust the examples according to your specific needs and use cases.
Contributing
Contributions are welcome! Fork the repository, make your enhancements, and submit a pull request.
License
This library is licensed under the MIT License.
Credits
The Effectra\Config library is developed and maintained by [Effectra].
Feel free to update and customize the content based on your specific library details. Don't forget to replace [link-to-documentation] and [Effectra] with appropriate links and information.
effectra/config 适用场景与选型建议
effectra/config 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 43 次下载、GitHub Stars 达 0, 最近一次更新时间为 2023 年 06 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 effectra/config 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 effectra/config 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 43
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 3
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-19