Skip to content

[Symfony CLI] Document about APP_ENV=test behavior #15228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions setup/symfony_server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down