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.
- π 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
composer require fast-forward/configuse function FastForward\Config\config;
$config = config(
['app' => ['env' => 'production']],
__DIR__ . '/config',
\Vendor\Package\ConfigProvider::class
);
echo $config->get('app.env'); // "production"$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.
use function FastForward\Config\configCache;
/** @var \Psr\SimpleCache\CacheInterface $cache */
$config = configCache($cache, ['foo' => 'bar']);
echo $config->get('foo'); // "bar"use function FastForward\Config\configFile;
$config = configFile(__DIR__ . '/config.php', persistent: true);
$config->set('app.env', 'staging'); // Persists changes back to config.phpuse function FastForward\Config\configDir;
$config = configDir(__DIR__ . '/config', recursive: true);use function FastForward\Config\configProvider;
$config = configProvider([
new Vendor\Package\Provider1(),
new Vendor\Package\Provider2(),
]);$config->set('db.host', 'localhost');
echo $config->get('db.host'); // "localhost"
$config->has('app.debug'); // true/false
print_r($config->toArray());config/
βββ app.php
βββ db.php
βββ services/
βββ mail.php
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
MIT Β© 2025 Felipe SayΓ£o Lobato Abreu
