Skip to content
php-fast-forwardPublic

About

Flexible and modern PHP configuration library built for performance, extendability, and lazy-loading behavior.

Topics

Resources

Code of conduct

Contributing

Security policy

Accessibility

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

58 Commits

Folders and files

FastForward Config

Dash combining configuration sources into structured settings

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.

PHP Version Composer Package Tests Coverage Docs License GitHub Sponsors


✨ 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): ConfigInterface
  • configFile(string $file, bool $persistent = false, array|ConfigInterface|null $defaultConfig = null): ConfigInterface
  • configCache(CacheInterface $cache, ...$configs): ConfigInterface
  • configDir(string $rootDirectory, bool $recursive = false, ?string $cachedConfigFile = null): ConfigInterface
  • configProvider(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

About

Flexible and modern PHP configuration library built for performance, extendability, and lazy-loading behavior.

Topics

Resources

Code of conduct

Contributing

Security policy

Accessibility

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages