Typed config compiler: turns a schema + environment into a tree of readonly PHP classes ($config->mail->smtp->host), never array-soup config('a.b.c').

Maintainers

Package info

github.com/codinglombok/config

pkg:composer/lombokclarion/config

Transparency log

Statistics

Installs: 0

Dependents: 3

Suggesters: 0

Stars: 0

Open Issues: 0

v2.1.0 2026-08-08 17:25 UTC

This package is auto-updated.

Last update: 2026-08-09 13:12:12 UTC


README

Schema-driven config: env resolved once at compile time, typed readonly classes at runtime.

[READ-ONLY] This is a subtree split of the LombokClarion monorepo.
Do not send pull requests here — contribute to the main repository instead.

Install

composer require lombokclarion/config

Namespace

LombokClarion\Config

What's Inside

Class Role
ConfigCompiler Reads a schema definition + .env → generates a readonly PHP class file
ConfigException Thrown on missing required env vars or schema violations

Usage

Define a schema in config/config.schema.php:

return [
    'app' => [
        'name' => ['type' => 'string', 'env' => 'APP_NAME', 'default' => 'LombokClarion'],
        'debug' => ['type' => 'bool', 'env' => 'APP_DEBUG', 'default' => false],
        'key' => ['type' => 'string', 'env' => 'APP_KEY', 'required' => true],
    ],
    'database' => [
        'driver' => ['type' => 'string', 'env' => 'DB_DRIVER', 'default' => 'sqlite'],
    ],
];

Compile:

use LombokClarion\Config\ConfigCompiler;

$compiler = new ConfigCompiler();
$compiler->compile(
    schema: require 'config/config.schema.php',
    outputPath: 'storage/config.compiled.php',
);

// At runtime — typed access, no env lookup:
$config = require 'storage/config.compiled.php';
$config->app->name;   // string
$config->app->debug;  // bool

License

Apache-2.0 — see LICENSE in the main repository.