From 6b105893cfe25b8b34cddd504a230d3c38e5220a Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Mon, 12 Apr 2021 23:21:43 +0200 Subject: [PATCH] [Symfony CLI] Document about `APP_ENV=test` behavior Running the Symfony CLI with `APP_ENV=test` has an interesting but undocumented behaviour, it updates `DATABASE_*` environment variables for a test environment. --- setup/symfony_server.rst | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/setup/symfony_server.rst b/setup/symfony_server.rst index f0723c20ea1..580af42bfba 100644 --- a/setup/symfony_server.rst +++ b/setup/symfony_server.rst @@ -322,6 +322,22 @@ prefixed with ``DB_``, but as the ``com.symfony.server.service-prefix`` is set to ``DATABASE``, the web server creates environment variables starting with ``DATABASE_`` instead as expected by the default Symfony configuration. +You don't need to create two containers for a main database and a test database. +Using `APP_ENV=test symfony` will automatically adjust `DATABASE_*` environment variables +for a test environment. + +.. code-block:: terminal + + $ symfony var:export --multiline + export DATABASE_DATABASE=app + export DATABASE_NAME=app + export DATABASE_URL=postgres://app:app@127.0.0.1:49160/app?sslmode=disable&charset=utf8 + + $ APP_ENV=test symfony var:export --multiline + export DATABASE_DATABASE=app_test + export DATABASE_NAME=app_test + export DATABASE_URL=postgres://app:app@127.0.0.1:49160/app_test?sslmode=disable&charset=utf8 + Here is the list of supported services with their ports and default Symfony prefixes: