Expand usage of Craft::parseBooleanEnv() to general.php
#10319
-
|
Right now it doesn't seem like you can use Desired:<?php
use Craft;
return [
'*' => [
'devMode' => Craft::parseBooleanEnv('$DEV_MODE'),
],
];Doing this will throw a fatal error (I truncated my folder paths out of here): ErrorRight now you can get around that, but it requires writing an expression like this Current<?php
use craft\helpers\App;
return [
'*' => [
'devMode' => App::env('DEV_MODE') === "true",
],
]; |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
This was a tricky one! So… just worked around this by moving use craft\helpers\App;
return [
'*' => [
'devMode' => App::parseBooleanEnv('$DEV_MODE'),
],
]; |
Beta Was this translation helpful? Give feedback.
This was a tricky one!
config/general.phpneeds to be loaded beforeCraft.php(where theCraftclass is defined) because we need to know whether Dev Mode should be enabled before loading Craft/Yii, so we can declare theYII_DEBUGconstant based on it. Otherwise, Yii will declare theYII_DEBUGconstant for us, setting it tofalse, and thedevModeconfig value will have no effect.So… just worked around this by moving
parseEnv()andparseBooleanEnv()over tocraft\helpers\Appfor the next release, where they can be called before Craft/Yii is loaded: