Skip to main content

Configuration

Configuration lives in config/. Each file returns an array and becomes the section named after the file: config/database.php is the database section. bootstrap.php loads the directory with Config::load() and passes the result to Application::create(), which validates every section at startup. Unknown keys, wrong types and out-of-range values stop the application with an InvalidConfigurationException naming the setting, for example server.port.

SectionPurposeDocumented in
appname, environment, debug, log levelbelow
serverlisten address, workers, process settingsRuntime
httpbody size limit, request timeout, request id headerRequests and responses
databaseMySQL/MariaDB connection and poolDatabase
redis, cacheRedis connection, cache defaultsRedis and cache
http_clientoutbound HTTP defaultsHTTP client
queuequeue name, worker concurrency, job classesQueues

Add your own files (for example config/payments.php) and read them with Config::get($app->config(), 'payments.api_url').

The app section​

KeyDefaultMeaning
nameOmnitrixapplication name
envproductionproduction, staging, local, testing; destructive console commands require --force in production
debugfalseexception details in 500 responses — never enable in production
log_levelinfominimum PSR-3 level written to the log

Environment variables​

Configuration files read the environment through Omnitrix\Config\Env. bootstrap.php loads .env first; real environment variables always win over .env.

// config/database.php
use Omnitrix\Config\Env;

return [
'host' => Env::get('DB_HOST', '127.0.0.1'),
'port' => Env::int('DB_PORT', 3306),
'password' => Env::required('DB_PASSWORD'), // fails at startup when missing
];
MethodReturns
Env::load(string $path)number of variables loaded; a missing file loads nothing
Env::get(string $name, ?string $default = null)the value or the default
Env::required(string $name)the value; throws InvalidConfigurationException when unset or empty
Env::int(string $name, int $default)the integer value; throws on non-integer input
Env::bool(string $name, bool $default)true/false/1/0/yes/no/on/off

.env syntax: KEY=value, export KEY=value, KEY="quoted # kept", # comments, KEY=value # trailing comment. Keep .env out of version control (the project's .gitignore does) and keep .env.example up to date with every variable the application reads. An empty value such as REDIS_PASSWORD= means "not set".

Reading configuration in code​

use Omnitrix\Config\Config;

$name = Config::string($app->config(), 'app.name', 'Omnitrix');
$jobs = Config::get($app->config(), 'queue.jobs', []);

Configuration is read once, in the master process, when the application starts. Change a value and restart (or reload with SIGUSR1) to apply it.