Open adriancuadrado opened 3 years ago
I just realized that maybe it wouldn't be worth it to remove the XDEBUG_MODE because that variable should be present before any php code gets executed to activate the debug mode. If you set it in the .env variable it wouldn't make sense because that won't tell php to use XDEBUG in debug mode. However, everything holds true for APP_ENV.
I can concur,
For me it only happens on Akeneo 5.0 during a migration.
I had issues trying to set APP_ENV to dev an nothing happens, to problem sadly is one of many layers.
docker-compose sets APP_ENV at start but you can't switch it anymore during, which is a shame and unneeded during development. APP_ENV should be a more flexible env variable to test more environments without the need to restart your docker container.
Also docker only reads .env during up while symfony reads .env and .env.local or .env.local.php as overrides, these are ignored by docker. Also the SetEnv is used here https://github.com/akeneo/pim-community-dev/blob/master/docker/akeneo.conf#L12 which is a best practice for production machines, but maybe not required and redundant for development containers.
composer update overrides your .env The file is created and overridden by Symfony, not by flex, flex is not found and the composer.json is standard. In a Symfony setup this is fine as the .env file has all the default values that keeps your app from breaking, .env.local has your overrides. So docker uses and override .env file where the default is prod.
I would like to add the following solution.
/docker/akeneo.conf
# remove
SetEnv APP_ENV ${APP_ENV}
This hard sets the APP_ENV as a variable in the Apache container which is not required for docker development.
Just, Remove the entry, restart your container, and use .env.local to overload your global variables.
/.env
# DON'T EDIT THIS FILE !
# IT COULD BE OVERWRITTEN DURING THE LAST UPDATE
# You must use .env.local to overload ENV VARs
APP_ENV=prod
APP_DEBUG=0
....
/.env.local
APP_ENV=dev
APP_DEBUG=1
:bug: I'm reporting a Bug :bug:
It's not really a bug, but I think it would be much better if you fix it: When I edit the APP_ENV and XDEBUG_MODE environment variables in my .env.local and I create a new extra variable as follows:
And then run a Symfony command that I create to print the values of those variables...
I get the following values:
The APP_ENV and XDEBUG_MODE variables are ignored, but not the MY_ENV_VARIABLE. This is so because the exported environment variables have precedence over those defined in .env and in .env.local. If you take a look at the docker-compose.yml file, you will see this:
docker-compose only reads .env and not .env.local and then executes the command passing the environment defined under
environment:
. Once the script is executed, because APP_ENV=prod and XDEBUG_MODE=off are defined in the environment that docker-compose provided to the command, they end up overriding the .env.local values (because those variables, while executing the command, are not read from .env or .env.local, but from the environment).My suggestion: Please remove the APP_ENV and XDEBUG_MODE environment variables from docker-compose. They are already defined in .env and is redundant and they will only cause problems like the one I mentioned above.