Closed Yivan closed 5 years ago
It is one of the main new feature of Pimcore 6 (.env file)
.env
support was already there in v5 ;)
@brusch Was it? I always had to create that myself using the constants.php or startup.php...
@brush Just added a PR to the base skeleton. I hope this could be merged so we can directly use the new Symfony 4.3 way to handle env variables. Thanks.
https://github.com/pimcore/pimcore/issues/4500 is resolved by the way.
@dpfaffenbauer it's been there since v5.0.0: https://github.com/pimcore/pimcore/blob/v5.0.0/pimcore/config/constants.php#L36
Just to not forget before closing this issue, would be great to have this added too: https://github.com/pimcore/skeleton/pull/10#issuecomment-510091013
@brush Thanks for those modifications.
The env new mechanism don't work well (last dev-master skeleton + dev-master pimcore 6).
In fact dotenv symfony use APP_ENV, and actually APP_ENV is always on 'dev' for a PIMCORE_ENVIRONMENT on 'int' for instance.
The result is that with a environment where PIMCORE_ENVIRONMENT is set to 'int', .env.dev
will be loaded and not .env.int
...
To fix it:
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $_SERVER['PIMCORE_ENVIRONMENT'];
should be added so APP_ENV match the same than PIMCORE_ENVIRONMENT.
Could be added here: https://github.com/pimcore/pimcore/blob/master/lib/Bootstrap.php#L129
@Yivan please see 1c995f426a517d1cf014b1d0e8dc10e2ec20ab2f that should fix the issue entirely. Thanks for a quick feedback!
@Yivan unfortunately there was an issue with 1c995f426a517d1cf014b1d0e8dc10e2ec20ab2f, so I had to revert it and implemented another approach: 4622d0198ca4d7539644754c5b7e2945be6bb740
@brusch I didn't had time to test https://github.com/pimcore/pimcore/commit/1c995f426a517d1cf014b1d0e8dc10e2ec20ab2f, but i just test last https://github.com/pimcore/pimcore/commit/4622d0198ca4d7539644754c5b7e2945be6bb740 and it works fine, thanks !!
I got just side questions please on this subject:
it means before APP_ENV was never defined (i was always thinking APP_ENV was setted somewhere in Pimcore at the same values than PIMCORE_ENVIRONMENT) before this fix. How does Symfony/External bundles/Console was aware of APP_ENV ? (as i imagine many fonctionnality rely on it).
Synfony 4 structure has evolved like public
directory instead web
directory, index.php
instead app.php
, etc. (http://fabien.potencier.org/symfony4-directory-structure.html), but when releasing Pimcore 6, symfony 3 structure has been keeped, i imagine this is for backward compatibility ? It will evolve in Pimcore 7 ?
I noticed some console action use public
directory (Symfony 4) instead web
directory by default. Is it something configurable somewhere by default by Pimcore so we don't have to set target directory to web
manually ? You can see this problem for instance with the command php bin/console presta:sitemaps:dump
, which print as you can see it is has been dumped in public
directory:
Dumping all sections of sitemaps into public directory
Created/Updated the following sitemap files:
sitemap.default.xml
sitemap.xml
Sure you can set target directory in the command line, but yould be nice it is default setted globally to web
directory.
Hello,
According to https://symfony.com/doc/current/configuration.html#managing-multiple-env-files, it could be possible to use
.env.local
or by environment .env files (like .env.stage.local or .env.stage).Pimcore has not implemented the changes of october 2018. : ( It would be really nice to include them by default. It is one of the main new feature of Pimcore 6 (.env file) and being able to use .local or .env.{env} or .env.{env}.local will bring all the power of this new feature!! Here is the roadmap to follow, it is just minor changes to Pimcore 6 i think, and it will be really usefull (i think to continuous integration, specific environment, etc.). https://symfony.com/doc/current/configuration/dot-env-changes.html#updating-my-application
By the way, the default .gitignore should be updated by adding all .local files so they are ignored by GIT:
And removing
.env
from .gitignore (should be in the commits).Thanks!