https://github.com/amitminer/libconfig-php
Help you to manage with Config Yaml :)
https://github.com/amitminer/libconfig-php
library php
Last synced: 9 months ago
JSON representation
Help you to manage with Config Yaml :)
- Host: GitHub
- URL: https://github.com/amitminer/libconfig-php
- Owner: Amitminer
- Created: 2023-06-24T09:05:54.000Z (about 3 years ago)
- Default Branch: dev
- Last Pushed: 2023-11-12T05:32:10.000Z (over 2 years ago)
- Last Synced: 2025-07-06T18:18:51.065Z (about 1 year ago)
- Topics: library, php
- Language: PHP
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
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](https://getcomposer.org/):
```bash
composer require amitxd/libconfig:^1.0
```
## Usage
### Initializing LibConfig
```php
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
```php
// Get a configuration value by key, providing a default value if not found
$value = $config->get('key', 'default_value');
```
### Setting Configuration Values
```php
// 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:
```php
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](LICENSE).
---