waffle-commons/config 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

waffle-commons/config

最新稳定版本:0.1.0-alpha4

Composer 安装命令:

composer require waffle-commons/config

包简介

Config component for Waffle framework.

README 文档

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.

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-25