fast-forward / config
Fast Forward Config utility classes
v1.1.1
2025-04-18 23:32 UTC
Requires
- php: ^8.1
- dflydev/dot-access-data: ^3.0
- laminas/laminas-config-aggregator: ^1.13
- psr/container: ^1.0||^2.0
- psr/simple-cache: ^3.0
Requires (Dev)
- coisa/php-cs-fixer: ^2.1
- phpspec/prophecy-phpunit: ^2.3
- phpunit/phpunit: ^9.6 || ^10.5 || ^11.5
This package is auto-updated.
Last update: 2025-04-18 23:32:44 UTC
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 php-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): ConfigInterface
configCache(CacheInterface $cache, ...$configs): ConfigInterface
configDir(string $dir, bool $recursive = false, ?string $cache = null): ConfigInterface
configProvider(iterable $providers, ?string $cache = null): ConfigInterface
๐ก License
MIT ยฉ 2025 Felipe Sayรฃo Lobato Abreu