1

My symfony project do not find pdo_mysql driver. I am using debian server. The same config works on OSX ok but not here. When I use php -m command it show driver and also the php -i |grep pdo_mysql show:

/etc/php/7.0/cli/conf.d/20-pdo_mysql.ini, API Extensions => mysqli,pdo_mysql pdo_mysql pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock 

This is my symfony configuration and paramters:

parameters: database_host: 127.0.0.1 database_port: 3306 database_name: bisol_time database_user: root database_password: root 

Config:

doctrine: dbal: driver: pdo_mysql host: "%database_host%" port: "%database_port%" dbname: "%database_name%" user: "%database_user%" password: "%database_password%" charset: UTF8 

So what can i do. I try everything and read every topic under this problem but i do not find the solution. Can anyone help me?

2
  • I find out thet it is a problem only with php 7. I install php 5 and the same configuration and it works. Anyone know why and how to do it in php 7? Commented Jan 11, 2017 at 21:26
  • Maybe because of different configs for CLI and webserver? Commented Jan 11, 2017 at 21:42

2 Answers 2

1

This is not related to the Symfony but for the system setup.

As you can see when you run PHP in CLI it uses the config from /etc/php/7.0/cli/conf.d/20-pdo_mysql.ini (notice the cli in the path). While when used by Apache it uses most likely /etc/php/7.0/apache2/conf.d/20-pdo_mysql.ini or similar.

You can either nevigate to /etc/php/7.0/ or create info.php with <?php phpinfo(); and see where the config files are.

It seems that in that PHP configuration for apache the driver is not installed.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes, I figure it out when I change the version of php that it is not symfony problem, but php configuration. I created simple php script using PDO to connect to database and it worked, but it did not work on SF project. This is why I suspect that is maybe somting with SF too? Alse i used php -i |grep ini to locate all config files and find the one with pdo_mysql it is /etc/php7/cli/conf.d/20-pdo_mysql.ini and inside is only extension=pdo_mysql.so and commnted priority.
it would be nice if you can accept my answer. Thanks.
1

I believe there is a different pdo for PHP 5. On my system (CentOS 6) I have php70u-pdo.i686. I checked by using yum list installed |grep pdo. I can't guide you to install on OSX, I suspect you need to use brew, but check to see if you can install pdo for PHP7 and enable it in your php.ini file.

That sounds like the problem.


EDIT # 2 Based on Comments

Can you try:

apt-get install php7.0 php7.0-mysql 

I think the mysql installs pdo as well. Try it. not sure if it will work.

1 Comment

No on OSX is no problem I done it already. The problem is on Debian server (my production server, OSX is my development machine personal computer) I solve the problem by uninstaling php7 from debian server and instaling php5. It works now, but i wolud like to know why so in the future when I will use php 7 that the app will work ok. And btw on osx i used brew yes. tnx

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.