Skip to content

Commit 6b10589

Browse files
authored
[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.
1 parent a370d63 commit 6b10589

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

setup/symfony_server.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,22 @@ prefixed with ``DB_``, but as the ``com.symfony.server.service-prefix`` is set
322322
to ``DATABASE``, the web server creates environment variables starting with
323323
``DATABASE_`` instead as expected by the default Symfony configuration.
324324

325+
You don't need to create two containers for a main database and a test database.
326+
Using `APP_ENV=test symfony` will automatically adjust `DATABASE_*` environment variables
327+
for a test environment.
328+
329+
.. code-block:: terminal
330+
331+
$ symfony var:export --multiline
332+
export DATABASE_DATABASE=app
333+
export DATABASE_NAME=app
334+
export DATABASE_URL=postgres://app:app@127.0.0.1:49160/app?sslmode=disable&charset=utf8
335+
336+
$ APP_ENV=test symfony var:export --multiline
337+
export DATABASE_DATABASE=app_test
338+
export DATABASE_NAME=app_test
339+
export DATABASE_URL=postgres://app:app@127.0.0.1:49160/app_test?sslmode=disable&charset=utf8
340+
325341
Here is the list of supported services with their ports and default Symfony
326342
prefixes:
327343

0 commit comments

Comments
 (0)