@@ -150,6 +150,9 @@ Configuration Classes and Environment Variables
150150When you instantiate a configuration class, any *namespaced * environment variables
151151are considered for merging into the configuration object's properties.
152152
153+ .. important :: You cannot add a new property by setting environment variables,
154+ nor change a scalar value to an array. See :ref: `env-var-replacements-for-data `.
155+
153156If the prefix of a namespaced variable exactly matches the namespace of the configuration
154157class, then the trailing part of the setting (after the dot) is treated as a configuration
155158property. If it matches an existing configuration property, the environment variable's
@@ -180,20 +183,26 @@ Since v4.1.5, you can also write with underscores::
180183
181184.. note :: When using the *short prefix* the property names must still exactly match the class defined name.
182185
186+ .. _env-var-replacements-for-data :
187+
183188Environment Variables as Replacements for Data
184189==============================================
185190
186191It is very important to always remember that environment variables contained in your **.env ** are
187- **only replacements for existing data **. This means that you cannot expect to fill your **.env ** with all
188- the replacements for your configurations but have nothing to receive these replacements in the
189- related configuration file(s).
192+ **only replacements for existing data **.
193+
194+ Simply put, you can change only the property value that exists in the Config class
195+ by setting it in your **.env **.
196+
197+ You cannot add a property that is not defined in the Config class, nor can you
198+ change it to an array if the value of the defined property is a scalar.
190199
191- The **.env ** only serves to fill or replace the values in your configuration files. That said, your
192- configuration files should have a container or receiving property for those. Adding so many variables in
193- your **.env ** with nothing to contain them in the receiving end is useless.
200+ For example, you cannot just put ``app.myNewConfig = foo `` in your **.env ** and
201+ expect your ``Config\App `` to magically have that property and value at run time.
194202
195- Simply put, you cannot just put ``app.myNewConfig = foo `` in your **.env ** and expect your ``Config\App ``
196- to magically have that property and value at run time.
203+ When you have the property ``$default = ['encrypt' => false] `` in your
204+ ``Config\Database ``, you cannot change the ``encrypt `` value to an array even if
205+ you put ``database.default.encrypt.ssl_verify = true `` in your **.env **.
197206
198207Treating Environment Variables as Arrays
199208========================================
0 commit comments