pimcore / pimcore

Core Framework for the Open Source Data & Experience Management Platform (PIM, MDM, CDP, DAM, DXP/CMS & Digital Commerce)
http://www.pimcore.com
Other
3.41k stars 1.44k forks source link

[Improvement] Update to new .env mechanism #4642

Closed Yivan closed 5 years ago

Yivan commented 5 years ago

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:

/.env.local
/.env.local.php
/.env.*.local

And removing .env from .gitignore (should be in the commits).

Thanks!

brusch commented 5 years ago

It is one of the main new feature of Pimcore 6 (.env file)

.env support was already there in v5 ;)

dpfaffenbauer commented 5 years ago

@brusch Was it? I always had to create that myself using the constants.php or startup.php...

Yivan commented 5 years ago

@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.

brusch commented 5 years ago

@dpfaffenbauer it's been there since v5.0.0: https://github.com/pimcore/pimcore/blob/v5.0.0/pimcore/config/constants.php#L36

Yivan commented 5 years ago

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

Yivan commented 5 years ago

@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

brusch commented 5 years ago

@Yivan please see 1c995f426a517d1cf014b1d0e8dc10e2ec20ab2f that should fix the issue entirely. Thanks for a quick feedback!

brusch commented 5 years ago

@Yivan unfortunately there was an issue with 1c995f426a517d1cf014b1d0e8dc10e2ec20ab2f, so I had to revert it and implemented another approach: 4622d0198ca4d7539644754c5b7e2945be6bb740

Yivan commented 5 years ago

@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:

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.