Home > Software engineering >  Symfony bdal Excepiton: could not find driver
Symfony bdal Excepiton: could not find driver

Time:10-18

On command line I get connection and desired entities, no driver error here:

php bin/console dbal:run-sql 'select * from ourtest'

But on web i get error:

        $this->connection->fetchAll('SELECT * FROM ourtest');

Handling "App\Application\Command\DocumentUpload\DocumentUploadCommand" failed: An exception occurred in driver: could not find driver

i tried

php -m display among others PDO, pdo_mysql, mysqli, mysqlnd

connection url from .env:

DATABASE_URL=mysql://xxx:xxx@mysql-db:3306/db_test_01?serverVersion=8.0

doctrine.yaml:

doctrine:
    dbal:
        dbname:               db_test_01
        host:                 mysql-db
        port:                 3306
        user:                 xxx
        password:             xxx
        driver:               pdo_mysql
        version:              8.0

CodePudding user response:

My guess is the command line and your webserver use different configurations of PHP or different installations altogether.

Here's how to find out: Put a phpinfo() call in a file on your webserver (Do not do that on production as it will expose sensitive data to anyone with access to this file!). Open that file in your browser and check where your PHP installation is located.

On the command line, you can run which php to see where the PHP binary is located.

Compare the two and see whether you are running on the same binary. If it is indeed the same, then you should check which .ini file is used by the web server. In that .ini file you should find the name of the mysql extension (pdo_mysql.so) and it should not be commented out (no preceding ;).

  • Related