The Quantum uses DotEnv and comes with
.env.example file in the root directory which should be renamed to
.env and where evnironment variables should be defined.
To retrieve an environment variable, there is a helper function in the Quantum framework called
env(). The second argument is the default value when no environment variable exists for the given key.
Environment based configuration
Sometimes you might want to have different configuration files for different environments to execute the same codebase with different config parameters. For that typical reason there is a special config parameter
app_env which can be defined in base
config.php and can be named anything you like, but for convenience usually it can be named as
local, etc, by default it's
production and reads the parameters from
'app_env' => 'staging',
app_env value is set to
statging, then the framework will look for environment variables in
.env.staging file, similarly if
app_env is equal to
local then the environment variables will be fetched from
.env.local file etc.