fast-forward/config
最新稳定版本:v1.4.0
Composer 安装命令:
composer require fast-forward/config
包简介
Fast Forward Config utility classes
README 文档
README
FastForward Config is a flexible and modern PHP configuration library built for performance, extendability, and lazy-loading behavior. It supports dot-notation keys, recursive directory loading, Laminas-compliant configuration providers, and optional PSR-16 caching.
✨ Features
- 🔑 Dot notation access:
config->get('app.env') - 📁 Load from arrays, directories, or providers
- ♻️ Lazy-loading with
__invoke() - 🧩 Aggregation of multiple sources
- 🗂 Recursive directory support
- 💾 Optional PSR-16 compatible caching
- 🔌 Compatible with Laminas ConfigProviders
📦 Installation
composer require fast-forward/config
🚀 Quick Start
Load configuration from multiple sources:
use FastForward\Config\{config, configDir, configCache}; use Symfony\Component\Cache\Simple\FilesystemCache; $config = config( ['app' => ['env' => 'production']], __DIR__ . '/config', \Vendor\Package\ConfigProvider::class ); echo $config->get('app.env'); // "production"
Cache configuration using PSR-16:
$cache = new FilesystemCache(); $config = configCache( cache: $cache, ['foo' => 'bar'] ); echo $config->get('foo'); // "bar"
Load from a recursive directory:
$config = configDir(__DIR__ . '/config', recursive: true);
Use Laminas-style providers:
$config = configProvider([ new Vendor\Package\Provider1(), new Vendor\Package\Provider2(), ]);
🧪 Access & Mutation
$config->set('db.host', 'localhost'); echo $config->get('db.host'); // "localhost" $config->has('app.debug'); // true/false print_r($config->toArray());
📁 Directory Structure Example
config/
├── app.php
├── db.php
└── services/
└── mail.php
🧰 API Summary
config(...$configs): ConfigInterfaceconfigCache(CacheInterface $cache, ...$configs): ConfigInterfaceconfigDir(string $dir, bool $recursive = false, ?string $cache = null): ConfigInterfaceconfigProvider(iterable $providers, ?string $cache = null): ConfigInterface
🛡 License
MIT © 2025 Felipe Sayão Lobato Abreu
统计信息
- 总下载量: 323
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-18