4

I'm in the process of upgrading a project from Symfony 2.3 to Symfony 3.4 and I'm a bit confused about the relationship between .env and .env.dist files. From what I understand, the relationship between them is the same as the relationship between parameters.yml and parameters.yml.dist in Symfony2. But in the older Symfony, parameters.yml would be updated automatically during composer update after prompting the user about using the parameters in parameters.yml.dist as defaults. In Symfony3 documentation, on the other hand, I can't find any reference to automatic copying of parameters. Do the parameters in .env.dist always need to be copied to .env manually? If there is a way to copy them automaticaly, are there packages similar to incenteev/composer-parameter-handler that help with managing parameters?

yvoloshin
  • 378
  • 6
  • 18

1 Answers1

2

You don't need anything like incenteev/composer-parameter-handler anymore. You can access ENV vars in your config. So you direclty use ENV vars in your config like this:

doctrine:
    dbal:
        default_connection:   default
        connections:
            default:
                dbname:   '%env(SYMFONY_DATABASE_NAME)%'
                user:     '%env(SYMFONY_DATABASE_USER)%'
                password: '%env(SYMFONY_DATABASE_PASSWORD)%'

The .env files only allow you to add ENV vars. Symfony does specifically only recommend to use .env in non production environments.

Community
  • 1
  • 1
toooni
  • 347
  • 2
  • 8