Symfony2: Doctrine "could not find driver"

Two days ago, I started coding webapp with Symfony. Right now I'm trying to use Doctrine to save a new user (I already created an Entity table and 'linked' in my database using the php app/console doctrine:generate:entities ).

When I use the HTTP POST request in my subscription form, Symfony tells me:

could not find driver

500 Internal Server Error - PDOException

I found many solutions on Google here as well, but none of them worked: /

The php -m command gives me:

...

PDO

PDO_MySQL

...

I do not understand why this does not work, because Doctrine can generate a User Entity and connect to the mysql database (since it created a table in it called "User" in it).

phpinfo () tells me that "PDO drivers" have "no value". I think why I have some kind of my problem.

He also tells me:

Configuration File (php.ini) Path: / etc / php5 / cli

Uploaded configuration file: /etc/php5/cli/php.ini

I added the following lines to the file /etc/php5/cli/php.ini and restarted the Apache server using the command /etc/init.d/apache2 restart, but it didn’t change anything = /

extension = php_mysql.so

extension = php_mysqli.so

extension = php_pdo_mysql.so

extension = pdo.so

"php -ini" now gives:

PHP Warning: starting PHP: unable to load the dynamic library '/usr/lib/php5/20100525/php_mysql.so' - / usr / lib / php5 / 20100525 / php_mysql.so: cannot open the shared objects file: file or directory in Unknown on line 0

PHP Warning: starting PHP: cannot load the dynamic library '/usr/lib/php5/20100525/php_mysqli.so' - / usr / lib / php5 / 20100525 / php_mysqli.so: cannot open the shared objects file: file or directory in Unknown on line 0

PHP Warning: starting PHP: cannot load the dynamic library '/usr/lib/php5/20100525/php_pdo_mysql.so' - / usr / lib / php5 / 20100525 / php_pdo_mysql.so: cannot open a shared objects file: file or directory in Unknown on line 0

PHP warning: PDO module is already loaded in Unknown on line 0

Configuration File (php.ini) Path: / etc / php5 / cli

Uploaded configuration file: /etc/php5/cli/php.ini

Scan additional .ini files in: /etc/php5/cli/conf.d

Additional .ini files were analyzed: /etc/php5/cli/conf.d/10-pdo.ini,

/etc/php5/cli/conf.d/20-curl.ini,

/etc/php5/cli/conf.d/20-gd.ini,

/etc/php5/cli/conf.d/20-mysql.ini,

/etc/php5/cli/conf.d/20-mysqli.ini,

/etc/php5/cli/conf.d/20-pdo_mysql.ini,

/etc/php5/cli/conf.d/20-pdo_pgsql.ini,

/etc/php5/cli/conf.d/20-pdo_sqlite.ini,

/etc/php5/cli/conf.d/20-pgsql.ini,

/etc/php5/cli/conf.d/20-sqlite3.ini

Where should pdo drivers be located? I guess I missed something?

+6
source share
1 answer

Most likely your problem is caused by the fact that pdo is not resolved for the PHP web server. PHP can have different configurations for the CLI and the web server. All your data is output from the PHP command line. But your php.ini CLI is ok, so the console is working. These are CGIs or FPMs that are not configured properly.

You need to find the CGI or FPM php.ini (the location may change depending on your installation - see this answer for more information) and make sure that the PDO and PDO driver that you want to use are used.

+1
source

Source: https://habr.com/ru/post/983972/


All Articles