fast-forward / config
Fast Forward Config utility classes
Requires
- php: ^8.3
- brick/varexporter: ^0.5 || ^0.6 || ^0.7
- laminas/laminas-config-aggregator: ^1.13
- psr/container: ^1.0 || ^2.0
- psr/simple-cache: ^3.0
Requires (Dev)
- fast-forward/dev-tools: dev-main
- symfony/cache: ^7.4
Suggests
- llm/skills: Optionally synchronize the bundled agent skill in consumer projects.
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-10-20 16:17:29 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, PHP files, directories, or providers
- ๐พ Optional persistence for single PHP files and PSR-16 cache
- โป๏ธ Lazy-loading with
__invoke() - ๐งฉ Aggregation of multiple sources
- ๐ Recursive directory support
- ๐ Compatible with Laminas ConfigProviders
๐ฆ Installation
composer require fast-forward/config
๐ Quick Start
Load configuration from multiple sources
use function FastForward\Config\config; $config = config( ['app' => ['env' => 'production']], __DIR__ . '/config', \Vendor\Package\ConfigProvider::class ); echo $config->get('app.env'); // "production"
Combine module lists
$config = config( ['console' => ['commands' => ['A', 'B']]], ['console' => ['commands' => ['C', 'A']]], ); $config->get('console.commands'); // ['A', 'B', 'C', 'A']
Source aggregation concatenates sequential lists in source order, retains duplicates,
merges maps recursively, and lets later scalar values win. Arrays, config objects,
PHP files, directories, and invokable provider class names use this behavior.
Direct set() retains its existing index-replacement behavior. See
the merge and boundary semantics.
Cache configuration using PSR-16
use function FastForward\Config\configCache; /** @var \Psr\SimpleCache\CacheInterface $cache */ $config = configCache($cache, ['foo' => 'bar']); echo $config->get('foo'); // "bar"
Load from a single PHP file (with optional persistence)
use function FastForward\Config\configFile; $config = configFile(__DIR__ . '/config.php', persistent: true); $config->set('app.env', 'staging'); // Persists changes back to config.php
Load from a recursive directory
use function FastForward\Config\configDir; $config = configDir(__DIR__ . '/config', recursive: true);
Use Laminas-style providers
use function FastForward\Config\configProvider; $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): ConfigInterfaceconfigFile(string $file, bool $persistent = false, array|ConfigInterface|null $defaultConfig = null): ConfigInterfaceconfigCache(CacheInterface $cache, ...$configs): ConfigInterfaceconfigDir(string $rootDirectory, bool $recursive = false, ?string $cachedConfigFile = null): ConfigInterfaceconfigProvider(iterable $providers, ?string $cachedConfigFile = null): ConfigInterface
Agent skill
The portable fast-forward-config skill
guides coding agents consuming the library, including version checks, composition,
paths, persistence, cache identities and PSR-11 integration. Its supported
contract is fast-forward/config ^1.7 on PHP 8.3+; inspect the application's
installed version before selecting APIs. See the
installation guide for manual project/global
copies, optional llm/skills project synchronization, pinned Skills CLI commands,
updates, rollback and removal. Composer ships the source files; the consumer
chooses installation and activation.
๐ก License
MIT ยฉ 2025 Felipe Sayรฃo Lobato Abreu
