Shopware 6: Use .env.local.php
As of Shopware 126.96.36.199 Shopware supports the settings to be written directly to an .env.local.php.
As of Shopware 188.8.131.52 (https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks#.env.local.php) Shopware supports the settings to be written directly to an .env.local.php. This function is a Symfony Core feature (https://symfony.com/doc/current/configuration.html#configuring-environment-variables-in-production). This means that the .env file does not have to be parsed for each request.
However, as of May 2022, Shopware does not yet provide a way to automatically generate the .env.local.php. Also, the Symfony tool Flex is not shipped with Shopware.
Currently, the .env.local.php must therefore still be generated manually.
Although Shopware does not yet offer the possibility to generate the .env.local.php automatically, it is still possible to use the .env.local.php file.
For this purpose, a corresponding file can be created based on the previous .env file. The syntax must be rewritten into a PHP array. A corresponding file can therefore look like the following:
<?php return array ( 'APP_ENV' => "prod", 'APP_SECRET' => "***", 'APP_URL' => "http://sw6.c-421.maxcluster.net", 'DATABASE_URL' => "mysql://db-user-1:***@localhost:3306/db-1", 'COMPOSER_HOME' => "/var/www/share/sw6.c-421.maxcluster.net/sw6/var/cache/composer", 'INSTANCE_ID' => "***", 'BLUE_GREEN_DEPLOYMENT' => "1", 'SHOPWARE_HTTP_CACHE_ENABLED' => "1", 'SHOPWARE_HTTP_DEFAULT_TTL' => "7200", 'SHOPWARE_ES_HOSTS' => "", 'SHOPWARE_ES_ENABLED' => "0", 'SHOPWARE_ES_INDEXING_ENABLED' => "0", 'SHOPWARE_ES_INDEX_PREFIX' => "sw", 'SHOPWARE_CDN_STRATEGY_DEFAULT' => "id" );