Config component for Waffle framework.

Installs: 2

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/waffle-commons/config

0.1.0-alpha4 2026-01-05 09:59 UTC

This package is auto-updated.

Last update: 2026-01-06 15:23:39 UTC


README

PHP Version Require PHP CI codecov Latest Stable Version Latest Unstable Version Total Downloads Packagist License

Waffle Config Component

A robust configuration management library for PHP, supporting YAML files and environment variable substitution.

📦 Installation

composer require waffle-commons/config

🚀 Usage

Basic Usage

use Waffle\Commons\Config\Config;

// Initialize Config with the path to your configuration directory and current environment
$config = new Config('/path/to/config/dir', 'prod');

// Retrieve a string value
$dbHost = $config->getString('database.host');

// Retrieve an integer with a default value
$port = $config->getInt('database.port', 3306);

// Retrieve a boolean
$debug = $config->getBool('app.debug', false);

Environment Variables

You can reference environment variables in your YAML files using the %env(VAR_NAME)% syntax:

# config/app.yaml
database:
  host: '%env(DB_HOST)%'
  password: '%env(DB_PASSWORD)%'

Environment Specifics

The loader automatically merges app.yaml with app_{env}.yaml. For example, if your environment is prod, it will load app.yaml and then override values with app_prod.yaml.

Testing

To run the tests, use the following command:

composer tests

Contributing

Contributions are welcome! Please refer to CONTRIBUTING.md for details.

License

This project is licensed under the MIT License. See the LICENSE.md file for details.