I recently started working with Symfony 4.
While developing I like to have two different environments: one for dev (surfing the site with some fake data that we have on fixtures) and one for testing where I execute behat tests that reset the database on each test.
In previous versions of symfony I just had two different databases: mysite_dev and mysite_test and two parameters files (parameters_dev.yml and parameters_test.yml) with the proper database configuration.
But with Symfony 4 and the .env configuration file I don't see the way of doing this. I don't see any way of having two sets of ddbb params and be able to run php bin/console doctrine:schema:update --env=test or php bin/console doctrine:schema:update --env=dev.
Any ideas? thanks!
how about using different url variables in your config?
# config/packages/dev/doctrine.yaml
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL_DEV)%'
# config/packages/test/doctrine.yaml
doctrine:
dbal:
url: '%env(resolve:DATABASE_URL_TEST)%'
also consider this comment from the default config file
parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
env(DATABASE_URL): ''