kynetcode/wpzylos-config
Composer 安装命令:
composer require kynetcode/wpzylos-config
包简介
Configuration management with dot-notation and .env support for WPZylos framework
README 文档
README
Configuration management with dot-notation and .env support for WPZylos framework.
📖 Full Documentation | 🐛 Report Issues
✨ Features
- Dot-notation Access — Read and write nested values with
get('app.name') - Environment Support — Parse
.envfiles with quote and escape handling - Type Safety — Typed accessors:
string(),int(),float(),bool(),array() - Directory Loading — Auto-load all PHP config files from a directory
- Deep Merging — Merge configuration arrays recursively
📋 Requirements
| Requirement | Version |
|---|---|
| PHP | ^8.0 |
🚀 Installation
composer require KYNetCode/wpzylos-config
📖 Quick Start
use WPZylos\Framework\Config\ConfigRepository; $config = new ConfigRepository([ 'app' => [ 'name' => 'My Plugin', 'debug' => true, ], 'database' => [ 'prefix' => 'myplugin_', ], ]); // Dot-notation access $config->get('app.name'); // 'My Plugin' $config->get('app.debug'); // true $config->get('missing', 'default'); // 'default' // Typed accessors $config->string('app.name'); // 'My Plugin' $config->bool('app.debug'); // true $config->int('database.port', 3306); // 3306
🏗️ Core Features
Dot-notation Access
$config->get('database.connections.mysql.host'); $config->set('database.connections.mysql.port', 3307); $config->has('database.connections.mysql'); // true
Typed Accessors
$config->string('app.name'); // Returns string, casts if needed $config->int('database.port', 3306); // Returns int $config->float('rate.tax', 0.15); // Returns float $config->bool('app.debug'); // Handles 'true', '1', 'yes', 'on' $config->array('app.providers', []); // Returns array or default
Loading from a Directory
$config = new ConfigRepository(); $config->loadDirectory(__DIR__ . '/config'); // Each PHP file becomes a top-level key: // config/app.php → $config->get('app.key') // config/database.php → $config->get('database.key')
Environment Variables
use WPZylos\Framework\Config\EnvLoader; $env = new EnvLoader(); $env->load(__DIR__ . '/.env'); // Instance methods $env->get('APP_DEBUG'); // Value from .env $env->has('DB_HOST'); // true/false $env->all(); // All parsed values // Static helper (checks $_ENV, then getenv()) EnvLoader::env('APP_DEBUG', false);
Deep Merging
$config->merge([ 'app' => ['version' => '2.0'], ]); // Existing app values preserved, 'version' added
📦 Related Packages
| Package | Description |
|---|---|
| wpzylos-core | Application foundation |
| wpzylos-container | Dependency injection |
| wpzylos-scaffold | Plugin template |
📖 Documentation
For comprehensive documentation, tutorials, and API reference, visit wpzylos.com.
☕ Support the Project
📄 License
MIT License. See LICENSE for details.
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Made with ❤️ by KYNetCode
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 3
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2026-06-16