Symfony2 : Doctrine "could not find driver"

16,513

Most likely your issue is caused by not having pdo enabled for webserver's PHP. PHP can have different configurations for CLI and webserver. All your output comes from the PHP CLI. But your CLI's php.ini is fine, that's why the console is working. It's the CGI or FPM that's not set up properly.

You need to locate CGI or FPM php.ini (location may change depending on your setup - refer to this answer for more info) and make sure that PDO and PDO driver you want to use is enabled there.

Share:
16,513
Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

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

    When i'm using a POST HTTP request on my subscribe form, Symfony tells me :

    could not find driver

    500 Internal Server Error - PDOException

    I found a lot of solution on Google and here, but none of them worked :/

    The command php -m gives me :

    ...

    PDO

    pdo_mysql

    ...

    I don't undestand why this isn't working, because Doctrine could generate the User Entity and connect to the mysql database (since it created a table named 'User' in it).

    phpinfo() tells me that "PDO drivers" has "no value". I guess that's why I have some my problem.

    Also, it tells me :

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

    Loaded Configuration File : /etc/php5/cli/php.ini

    I added the following lines in the file "/etc/php5/cli/php.ini" and restarted the apache server with the "/etc/init.d/apache2 restart" command, but it changed nothing =/

    extension=php_mysql.so

    extension=php_mysqli.so

    extension=php_pdo_mysql.so

    extension=pdo.so

    "php --ini" now yields :

    PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/php_mysql.so' - /usr/lib/php5/20100525/php_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0

    PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/php_mysqli.so' - /usr/lib/php5/20100525/php_mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0

    PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/php_pdo_mysql.so' - /usr/lib/php5/20100525/php_pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0

    PHP Warning: Module 'PDO' already loaded in Unknown on line 0

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

    Loaded Configuration File: /etc/php5/cli/php.ini

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

    Additional .ini files parsed: /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 are supposed to be located the pdo drivers ? I guess I'm missing something ?