php - Doctrine insists on trying to use PostgreSQLDriver despite contrary configGet the solution ↓↓↓
I am setting up a Symfony 5.2 app, using
doctrine/doctrine-bundle 2.4 and
doctrine/orm 2.9. My
doctrine.yaml config file looks like this:
# IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file)
The problem is that when I run
doctrine:fixtures:load, I get the following output:
In AbstractPostgreSQLDriver.php line 102:
An exception occurred in driver: could not find driver
In Exception.php line 18:
could not find driver
In PDOConnection.php line 39:
could not find driver
It looks like Doctrine is trying to use the Postgre driver, though I have specified MySQL. Is there another place where I need to configure this? If so, how?
EDIT: It looks like
DATABASE_URL is not available inside my Docker container, which is probably the source of the problem. I've verified that
DATABASE_URL is defined in my
.env file, and that my
.env file is in the same folder as my
docker-compose.yml file. Also, I have a setting like this for the environment variable in that docker-compose file:
So I'm not quite sure what's wrong here.
I think you have a wrong
DATABASE_URL in your
.env file. Please check if it starts with
I believe symfony uses dotenv package to load the values from .env to the
S_ENV superglobal. You need to debug whether your dotenv (and there is a .env in your project and it is not .env.local or .env.dist) is loaded properly.
It has happened to me sometimes when I was starting, typically when cloning a Github project which has a default .env file created by Doctrine when it's installed through composer that by default Doctrine uses PostgreSQL URL.
See how many .env files have you document and I'm sure that someone overrides your URL connection.
See this StackOverflow post to know the difference between the .env.* files What is the difference between .env.local and .env.development.local
Share solution ↓
Link To Answer People are also looking for solutions of the problem: port 80 in use by "unable to open process" with pid 4!
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.