This PR adjusts the way environment-specific config settings (devMode, allowAdminChanges, and disallowRobots) are configured for new Craft projects.
Instead of config/general.php being responsible for deciding their values based on CRAFT_ENVIRONMENT, each environment is now responsible for setting DEV_MODE, ALLOW_ADMIN_CHANGES, and DISALLOW_ROBOTS environment variables individually.
If any of the environment variables are missing, config/general.php will default the setting to false. In each case, that felt like the safest option if the developer had simply forgotten to set the environment variable.
The stock .env.example file has been copied to three separate files based on the common types of environments, with the recommended settings for each one:
File
DEV_MODE
ALLOW_ADMIN_CHANGES
DISALLOW_ROBOTS
.env.example.dev
true
true
true
.env.example.staging
false
false
true
.env.example.production
false
false
false
Obligatory environment variable override mention…
It’s a little awkward that these environment variable names are so similar to the environment variable override names (CRAFT_DEV_MODE etc.). Had we gone with those, it wouldn’t have been necessary to pull the values in manually from config/general.php in the first place.
However it was decided that it’s more important to be able to see exactly which config settings are being used by glancing at config/general.php, than to avoid writing a couple lines of code.
That said, there’s nothing stopping an individual project from using the environment variable overrides if they want to.
This PR adjusts the way environment-specific config settings (
devMode
,allowAdminChanges
, anddisallowRobots
) are configured for new Craft projects.Instead of
config/general.php
being responsible for deciding their values based onCRAFT_ENVIRONMENT
, each environment is now responsible for settingDEV_MODE
,ALLOW_ADMIN_CHANGES
, andDISALLOW_ROBOTS
environment variables individually.If any of the environment variables are missing,
config/general.php
will default the setting tofalse
. In each case, that felt like the safest option if the developer had simply forgotten to set the environment variable.The stock
.env.example
file has been copied to three separate files based on the common types of environments, with the recommended settings for each one:DEV_MODE
ALLOW_ADMIN_CHANGES
DISALLOW_ROBOTS
.env.example.dev
true
true
true
.env.example.staging
false
false
true
.env.example.production
false
false
false
Obligatory environment variable override mention…
It’s a little awkward that these environment variable names are so similar to the environment variable override names (
CRAFT_DEV_MODE
etc.). Had we gone with those, it wouldn’t have been necessary to pull the values in manually fromconfig/general.php
in the first place.However it was decided that it’s more important to be able to see exactly which config settings are being used by glancing at
config/general.php
, than to avoid writing a couple lines of code.That said, there’s nothing stopping an individual project from using the environment variable overrides if they want to.
Related