I have following server variable inphpunit.xml:
<php> <server name="APP_DEBUG" value="false"/></php>Sometimes while developing, I want haveAPP_DEBUG enabled. What I usually do is add it into CLI command:
APP_DEBUG=true phpunit -c phpunit.xmland in PHP:
$appDebug = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? null;But this does not set$_SERVER['APP_DEBUG] totrue, but leaves value from XML.
Is there any way to overwrite it from CLI?
1 Answer1
don't use<server> for this. Use<env> and read it viagetenv().
APP_DEBUG=true phpunit sets an environment variable, which is visible viagetenv() /$_ENV, not$_SERVER.
Inphpunit.xml
<php> <!-- default off --> <env name="APP_DEBUG" value="false" force="false"/></php>InPHP
$appDebug = getenv('APP_DEBUG') ?? ($_ENV['APP_DEBUG'] ?? null);// if you want a real boolean:$debug = filter_var($appDebug, FILTER_VALIDATE_BOOLEAN);Now in CLI
APP_DEBUG=true vendor/bin/phpunit -c phpunit.xml Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.

