skip to Main Content

I am making my first app with Symfony and when i setup my database (doesn’t matter if it’s postgresql or mysql).

I have an error "could not find driver" three time.
One in PDOConnection.php line 38.

Other in Exception.php line 18.

And last one in AbstractMySQLDriver.php line 128.

What i made : i check the php path i also check all the extensions. I check if i fill correctly .env and i check those folders.

PHP version : 7.4

And mysql in docker containers: mysql:5.7.

I really have no idea what to do now

UPDATE:

The problem (for me) was the command php bin/console doctrine:database:create

if you have the same problem try symfony doctrine:database:create

2

Answers


  1. Apparently you use Docker, but in your question you mentioned Windows cmd. I suppose, you check PDO extension in your host system, not in container. You need to log into your Docker PHP container and check it there. In Windows Desktop version of Docker there is a button near each container to open command-line interface. You also can use command:

    docker exec -it <here goes your container name>
    

    To find out what your container name is, you can use command

    docker ps
    

    UPDATE:

    To start your project not in Docker, bun on Windows-host itself, you can use very helpful mini-server, provided by Symfony. Run this command inside your project directory:

    symfony serve
    

    It will start local server, available by default at address https://127.0.0.1:8000/.

    However, keep in mind, that if your project requires database, you will need to have MySQL Server for Windows installed on your host system too.

    Login or Signup to reply.
  2. do you use .env file? I have same problem and after a day of disable/enable pdo without any effect, i found that symfony auto add a line to my .env file:

    DATABASE_URL=postgresql://db_user:[email protected]:5432/db_name?serverVersion=11&charset=utf8
    

    That make my database url wrong and error not found pdo fire because of postgresql not mysql

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search