Symfony caches all configuration parameters so even changing the varaible will not rebuild the cache and if you manually rebuild the cache it takes a good second to complete.
PR to add fetching of variables directly from the environment is in the works: symfony/symfony#18155
<?php
echo base64_encode(json_encode([
'database' => [
[
'query' => ['is_master' => true],
'scheme' => 'mysql',
'host' => 'mysql.example.com',
'port' => 3306,
'name' => 'platform_test_mysql',
'username' => 'somebody',
'password' => 'topS3kret',
'path' => ''
],
]])), PHP_EOL;
// Produces eyJkYXRhYmFzZSI6W3sicXVlcnkiOnsiaXNfbWFzdGVyIjp0cnVlfSwic2NoZW1lIjoibXlzcWwiLCJob3N0IjoibXlzcWwuZXhhbXBsZS5jb20iLCJwb3J0IjozMzA2LCJuYW1lIjoicGxhdGZvcm1fdGVzdF9teXNxbCIsInVzZXJuYW1lIjoic29tZWJvZHkiLCJwYXNzd29yZCI6InRvcFMza3JldCIsInBhdGgiOiIifV19
git clone [email protected]:platformsh/platformsh-example-symfony.git
cd platformsh-example-symfony
composer install --no-dev --no-scripts
export PLATFORM_RELATIONSHIPS="eyJkYXRhYmFzZSI6W3sicXVlcnkiOnsiaXNfbWFzdGVyIjp0cnVlfSwic2NoZW1lIjoibXlzcWwiLCJob3N0IjoibXlzcWwuZXhhbXBsZS5jb20iLCJwb3J0IjozMzA2LCJuYW1lIjoicGxhdGZvcm1fdGVzdF9teXNxbCIsInVzZXJuYW1lIjoic29tZWJvZHkiLCJwYXNzd29yZCI6InRvcFMza3JldCIsInBhdGgiOiIifV19"
app/console cache:clear --env prod --no-debug
grep -5R topS3kret app/cache/prod/
Environment variables are written into the compiled container and Symfony will not detect any changes.
app/cache/prod/appProdProjectContainer.php- }
app/cache/prod/appProdProjectContainer.php- protected function getDoctrine_Dbal_DefaultConnectionService()
app/cache/prod/appProdProjectContainer.php- {
app/cache/prod/appProdProjectContainer.php- $a = new \Symfony\Bridge\Doctrine\ContainerAwareEventManager($this);
app/cache/prod/appProdProjectContainer.php- $a->addEventListener(array(0 => 'loadClassMetadata'), $this->get('doctrine.orm.default_listeners.attach_entity_listeners'));
app/cache/prod/appProdProjectContainer.php: return $this->services['doctrine.dbal.default_connection'] = $this->get('doctrine.dbal.connection_factory')->createConnection(array('driver' => 'pdo_mysql', 'host' => 'mysql.example.com', 'port' => 3306, 'dbname' => '', 'user' => 'somebody', 'password' => 'topS3kret', 'charset' => 'UTF8', 'driverOptions' => array(), 'defaultTableOptions' => array()), new \Doctrine\DBAL\Configuration(), $a, array());
app/cache/prod/appProdProjectContainer.php- }
app/cache/prod/appProdProjectContainer.php- protected function getDoctrine_Orm_DefaultEntityListenerResolverService()
app/cache/prod/appProdProjectContainer.php- {
app/cache/prod/appProdProjectContainer.php- return $this->services['doctrine.orm.default_entity_listener_resolver'] = new \Doctrine\ORM\Mapping\DefaultEntityListenerResolver();
app/cache/prod/appProdProjectContainer.php- }
--
app/cache/prod/appProdProjectContainer.php- 'kernel.container_class' => 'appProdProjectContainer',
app/cache/prod/appProdProjectContainer.php- 'database_host' => 'mysql.example.com',
app/cache/prod/appProdProjectContainer.php- 'database_port' => 3306,
app/cache/prod/appProdProjectContainer.php- 'database_name' => '',
app/cache/prod/appProdProjectContainer.php- 'database_user' => 'somebody',
app/cache/prod/appProdProjectContainer.php: 'database_password' => 'topS3kret',
app/cache/prod/appProdProjectContainer.php- 'mailer_transport' => 'mail',
app/cache/prod/appProdProjectContainer.php- 'mailer_host' => NULL,
app/cache/prod/appProdProjectContainer.php- 'mailer_user' => NULL,
app/cache/prod/appProdProjectContainer.php- 'mailer_password' => NULL,
app/cache/prod/appProdProjectContainer.php- 'secret' => 'ThisTokenIsNotSoSecretChangeIt',