Each ConfigLoader instance is locked to one format.
YAML is the default format.
use LiquidRazor\ConfigLoader\ConfigLoader;
use LiquidRazor\ConfigLoader\Value\LoaderOptions;
$loader = new ConfigLoader(
new LoaderOptions(
configRoot: __DIR__ . '/config',
),
);Accepted extensions:
.yaml.yml
JSON must be selected explicitly.
use LiquidRazor\ConfigLoader\ConfigLoader;
use LiquidRazor\ConfigLoader\Enum\ConfigFormat;
use LiquidRazor\ConfigLoader\Value\LoaderOptions;
$loader = new ConfigLoader(
new LoaderOptions(
configRoot: __DIR__ . '/config',
format: ConfigFormat::JSON,
),
);Accepted extension:
.json
JSON also requires PHP ext-json. If that extension is unavailable, construction fails with MissingJsonExtensionException.
- selecting YAML while only
.jsonexists throwsUnsupportedFormatException - selecting JSON while only
.yamlor.ymlexists throwsUnsupportedFormatException - selecting JSON without
ext-jsonthrowsMissingJsonExtensionException