waffle-commons / config
Config component for Waffle framework.
0.1.0-alpha4
2026-01-05 09:59 UTC
Requires
- php: ^8.5
- ext-yaml: *
- waffle-commons/contracts: 0.1.0-alpha4
Requires (Dev)
- carthage-software/mago: ^1.0.0-rc
- php-mock/php-mock-phpunit: ^2.13
- phpunit/phpunit: ^12.0
- vimeo/psalm: ^6.13
- dev-main
- 0.1.0-alpha4
- 0.1.0-alpha3
- dev-dependabot/composer/vimeo/psalm-6.16.1
- dev-dependabot/composer/carthage-software/mago-1.15.3
- dev-dependabot/composer/carthage-software/mago-1.14.1
- dev-dependabot/composer/vimeo/psalm-6.15.1
- dev-dependabot/composer/php-mock/php-mock-phpunit-2.15.0
- dev-dependabot/composer/phpunit/phpunit-12.5.8
- dev-feature/hardening
- dev-pre-release/alpha5
This package is auto-updated.
Last update: 2026-03-23 21:19:15 UTC
README
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.