Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
552 views
in Technique[技术] by (71.8m points)

php - Symfony 5 exception Could not find driver

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

question from:https://stackoverflow.com/questions/65945892/symfony-5-exception-could-not-find-driver

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...