| CARVIEW |
Select Language
HTTP/2 200
date: Sun, 28 Dec 2025 13:50:11 GMT
content-type: text/html; charset=utf-8
server: cloudflare
last-modified: Sun, 28 Dec 2025 00:21:46 GMT
access-control-allow-origin: *
expires: Sun, 28 Dec 2025 14:00:11 GMT
cache-control: max-age=600
report-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=jcyIhASe38etnb1b5TBAjMUkTDJl6WYX3YB4VYzsDdSjHTwXoSQY%2BlerPjlDrlhm7Zpbp190IPbiXdbGVyxsq6d3o7dX2EKBfaV5MoEY%2FD53FFo02vpO"}]}
x-proxy-cache: MISS
x-github-request-id: E0C5:2D8B9D:7AB4F4:8990D3:69513593
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
age: 0
via: 1.1 varnish
x-served-by: cache-bom-vanm7210037-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1766929812.767269,VS0,VE208
vary: Accept-Encoding
x-fastly-request-id: 0bd143ff4a2168d2c83b1f81ec6c81051074756f
cf-cache-status: DYNAMIC
content-encoding: gzip
cf-ray: 9b51867b4f2134be-BOM
alt-svc: h3=":443"; ma=86400
league/config - Simple yet expressive configuration library for PHP apps
Config
Simple yet expressive configuration library for PHP apps
$ composer require league/config
Highlights
league/config helps you define configuration arrays with strict schemas and easy access to values with dot notation.
Easy-to-use, expressive API
Supports configuration schemas, allowed types, validation, deprecation, and more
Simplified access to nested configuration options using `parent.child` syntax
Define everything with code - no XML, YAML, or JSON required
Features
Expressive, Fluent API
use League\Config\Configuration;
use Nette\Schema\Expect;
$config = new Configuration([
'database' => Expect::structure([
'driver' => Expect::anyOf('mysql', 'postgresql', 'sqlite')->required(),
'host' => Expect::string()->default('localhost'),
'port' => Expect::int()->min(1)->max(65535),
'database' => Expect::string()->required(),
'username' => Expect::string()->required(),
'password' => Expect::string()->nullable(),
]),
]);
Easily Access Nested Values
echo $config->get('database.driver');
// or using slashes, if you prefer that syntax:
echo $config->get('database/driver');
Set Options Individually Or Together
use League\Config\Configuration;
$config = new Configuration([/*...*/]);
$config->merge([
'database' => [
'driver' => 'mysql',
'port' => 3306,
'host' => 'localhost',
'database' => 'myapp',
'username' => 'myappdotcom',
'password' => 'hunter2',
],
]);
if ($_ENV['APP_ENV'] === 'prod') {
$config->set('payment_gateway.test_mode', false);
}
Combine Multiple Schemas Into One
use League\Config\Configuration;
$config = new Configuration();
$config->addSchema('database', DB::getConfigSchema());
$config->addSchema('logging', Logger::getConfigSchema());
$config->addSchema('mailer', Mailer::getConfigSchema());
Questions?
Config was created by Colin O'Dell. Find him on Twitter at @colinodell.