Quick Start

This page gives you a complete first example and then points you to the sections that explain each piece in more detail.

A First Working Example

<?php

declare(strict_types=1);

use function FastForward\Config\config;

final class AppConfigProvider
{
    public function __invoke(): array
    {
        return [
            'app.locale' => 'en_US',
            'features' => [
                'search' => true,
            ],
        ];
    }
}

$config = config(
    ['app.name' => 'Example App', 'app.env' => 'production'],
    __DIR__ . '/config',
    AppConfigProvider::class,
);

echo $config->get('app.name'); // Example App
echo $config->get('app.locale'); // en_US
echo $config->get('database.host', '127.0.0.1'); // fallback when the key is missing

Loading Only From A Directory

If all your configuration already lives in PHP files, use configDir() directly:

use function FastForward\Config\configDir;

$config = configDir(__DIR__ . '/config', recursive: true);

echo $config->get('app.name', 'Unnamed application');

Using Providers Explicitly

If you prefer module-style provider classes, configProvider() makes that intent explicit:

use function FastForward\Config\configProvider;

$config = configProvider([
    new AppConfigProvider(),
]);

Next Steps