Installation

Description

We mainly use this extension to configure our dockerized yii2 applications.
It's good practice to build your docker applications in such a way,
that the runtime configuration in productive mode happens solely via environment variables.

But during local development we can loosen these strict requirement a little as we
sometimes have to add debug options or the like that should not be part of the main
configuration. Here the extension helps to override settings with local configuration
files that live outside of version control.

You have several options how to use this extension:

Use only the Yii environment initialization

Use only the configuration loader

Use both

We first show how to use the first two options "standalone" and then a third,
combined way that includes all features.

1. Initializing Yii environment

This will set the YII_DEBUG and YII_ENV variables according to the respective
environment variables if those are set. It can also load them from a .env file.

2. Loading configuration

If want to load your configuration with this extenstion, the following naming scheme
must be followed:

config/web.php - Web configuration

config/console.php - Console configuration

config/local.php - Local overrides for the web configuration (optional)

config/local-console.php - Local overrides for the console configuration (optional)

If you only want to load configuration from files but whithout initializing the Yii
environments as shown above, you'd create a Config instance and pass the application
base directory and, as second argument, false to the constructor:

2.1 Local configuration

By default local configuration files local.php and local-console.php are not
loaded. To activate this feature you can either set the ENABLE_LOCALCONF environment
variable (either in your server environment or in .env):