New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.env
files processed twice, booting not consistent between web and CLI
#16638
Comments
To be consistent I'd do the following:
Shouldn't break anything right? |
Thank you for the feedback! On index.php and CLI seem that the suggested change would be fine and safe so far. Looks like it would be breaking the install script instead Line 46 in f8a4c7a
since it's not loading the runtime one Line 30 in f8a4c7a
So if i got correctly, prepareEnvVariables was more for PIMCORE_COMPOSER_PATH to be changed by the value set in env before defining the Constant or something like that
|
@kingjia90 Regarding the installer: |
Thank you for the feedback, i've applied the requested change to #16652 and seems working fine so far |
After Updating to 11.2.0 .env variables are not set anymore. Could this be that our project was migrated from Pimcore 10? Our index.php - looks like this:
|
You should probably update your See: https://github.com/pimcore/skeleton/blob/11.x/public/index.php |
@brusch @kingjia90 Should be added to the upgrade notes if Symfony Runtime is required now in Pimcore 11. |
@danielerne @jdreesen @blankse plz have a look at #16796 - i's kind of a poor mans solution, but should do the job for backwards compatibility. Thanks for your feedback 😊 |
@brusch Is Pimcore 11.1 compatible with runtime? I am having the issue to support both in CoreShop for testing purposes. |
@dpfaffenbauer yeah, should be, since parts were using it already before, see: https://github.com/pimcore/skeleton/pull/183/files |
@brusch we just updated to pimcore 11.2.2 and now APP_ENV=prod from our .env file is ignored by CLI.
We adjusted our index.php to the one from skeleton: https://github.com/pimcore/skeleton/blob/11.x/public/index.php Is this intended behaviour? |
Did you also adjust your |
Thank you @jdreesen totally missed that. Added it to the docs. |
@Cruiser13 I'm wondering why you're experiencing the issue ... how did your I'd assume you missed the upgrade of the file earlier 😉 |
@brusch you are right, looks like we missed pimcore/skeleton@b1075d6 before. Worked fine until the update though. |
I'm getting the same error when running tests. How do I need to setup my tests/bootstrap.php in order to work again? The one used in skeleton does not help |
@patrick-rudolph-umusic declare(strict_types=1);
use Pimcore\Bootstrap;
use Symfony\Component\Dotenv\Dotenv;
include __DIR__ . '/../vendor/autoload_runtime.php';
if (method_exists(Dotenv::class, 'bootEnv')) {
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
}
Bootstrap::setProjectRoot();
Bootstrap::bootstrap(); |
Improvement description
Pimcore is using Symfony Runtime for bootstrapping.
Symfony runtime is using DotEnv (when available) and does parsing
.env
file.Pimcore is also using DotEnv here:
pimcore/lib/Bootstrap.php
Line 125 in 2ab61df
So `.env' file are getting processed twice during bootstrapping.
Also booting is not consistent between CLI and web.
For web
Bootstrap::bootstrap()
is called before the callback:https://github.com/pimcore/demo/blob/6978c2d36e9f580e22654e9970aa411487f320e0/public/index.php#L23
however for CLI, it's called inside the callback as part of
startupCli()
:https://github.com/pimcore/demo/blob/6978c2d36e9f580e22654e9970aa411487f320e0/bin/console#L36
This could cause very weird behavior, especially when doing some stuff in
config/pimcore/startup.php
, e.g. overriding env variables, which are then again overridden from values in.env
.The text was updated successfully, but these errors were encountered: