You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe it would be better to comment out or completely remove this line. Users who only use DBAL and NOT the ORM will wonder why they cannot change the DATABASE_URL via .env.
In addition: The part "@database:5432" could directly hint to a image name.
The text was updated successfully, but these errors were encountered:
I think there are several issues here related to DATABASE_URL, spent half a day for :-) To summarise, its a bit confusing when expecting to set only these .env vars in dev:
environment:
# Run "composer require symfony/orm-pack" to install and configure Doctrine ORM
DATABASE_URL: postgresql://${POSTGRES_USER:-app}:${POSTGRES_PASSWORD:-!ChangeMe!}@database:5432/${POSTGRES_DB:-app}?serverVersion=${POSTGRES_VERSION:-14}
# Run "composer require symfony/mercure-bundle" to install and configure the Mercure integration
... but then having the docker compose build (at composer dump-env prod;) failed, where environment vars are not available and the .env.local is .dockerignored through COPY or the override linked volume.
So still keeping the DATABASE_URL in .env as a required placeholder:
Recently I installed a Symfony 6 app with Symfony Docker. I needed Doctrine DBAL but did not want to add the entire ORM.
Unfortunately the DBAL and ORM are currently coupled:
doctrine/DoctrineBundle#973
So I installed Doctrine DBAL and the bundle. The Symfony recipe created the following file:
And adds the following parameters to .env:
I edited the DATABASE_URL using some pre-defined POSTGRES parameters:
But got:
An exception occurred in the driver: SQLSTATE[08006] [7] could not translate host name "database" to address: Try again
For some reason the doctrine.yaml was not accepting my .env parameters.
I copied my DATABASE_URL directly there to see if my connection works at all.
And indeed it did work. I looked up the "database" host name. It is defined in (docker-)compose.yaml
https://github.com/dunglas/symfony-docker/blob/main/docker-compose.yml#L21
Maybe it would be better to comment out or completely remove this line. Users who only use DBAL and NOT the ORM will wonder why they cannot change the DATABASE_URL via .env.
In addition: The part "@database:5432" could directly hint to a image name.
The text was updated successfully, but these errors were encountered: