amitxd/libconfig
最新稳定版本:1.0.0
Composer 安装命令:
composer require amitxd/libconfig
包简介
A library that helps users manage YAML configuration files.
README 文档
README
LibConfig-PHP
LibConfig-PHP is a PHP library that simplifies the management of YAML configuration files.
Installation
You can install this library using Composer:
composer require amitxd/libconfig:^1.0
Usage
Initializing LibConfig
use AmitxD\LibConfig\LibConfig; // Initialize LibConfig with the path to your YAML configuration file $config = new LibConfig('path/to/your/config.yaml');
Getting Configuration Values
// Get a configuration value by key, providing a default value if not found $value = $config->get('key', 'default_value');
Setting Configuration Values
// Set a configuration value by key $config->set('key', 'new_value'); // Save the changes back to the YAML file $config->save();
Example
Here's a simple example of how to use LibConfig:
use AmitxD\LibConfig\LibConfig; // Initialize LibConfig with the path to your YAML configuration file $config = new LibConfig('config.yaml'); // Get a configuration value $siteTitle = $config->get('site.title', 'My Website'); // Output the site title echo "Site Title: $siteTitle\n"; // Set a new configuration value $config->set('site.title', 'Updated Website Title'); // Save the changes back to the YAML file $config->save();
Requirements
- PHP ^8.0
- Symfony Yaml Component ^6.3
License
This library is open-source software licensed under the MIT License.
统计信息
- 总下载量: 269
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-09-07