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): Error
Right 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.php
needs to be loaded beforeCraft.php
(where theCraft
class is defined) because we need to know whether Dev Mode should be enabled before loading Craft/Yii, so we can declare theYII_DEBUG
constant based on it. Otherwise, Yii will declare theYII_DEBUG
constant for us, setting it tofalse
, and thedevMode
config value will have no effect.So… just worked around this by moving
parseEnv()
andparseBooleanEnv()
over tocraft\helpers\App
for the next release, where they can be called before Craft/Yii is loaded: