2
votes

When i do the command php bin/console doctrine:database:create i have these errors :

In AbstractMySQLDriver.php line 126: An exception occurred in driver: could not find driver

In PDOConnection.php line 50: could not find driver

In PDOConnection.php line 46: could not find driver


config/packages/doctrine.yaml

doctrine:
dbal:
    # configure these for your database server
    driver: 'pdo_mysql'
    server_version: '5.7'
    charset: utf8mb4
    default_table_options:
        charset: utf8mb4
        collate: utf8mb4_unicode_ci

.env

DATABASE_URL=mysql://root:[email protected]:3306/blogMyProject

My PHP Extensions: My PHP Extensions

php.ini extensions: php.ini extensions

PHP 7.2.7 - MySQL 5.7.11 - Symfony 4.1.4 - I use UwAmp 3.1.0 - I'm on Windows

I don't understand where these errors come from.

5
Do you have a seperate php.ini for the PHP CLI in UwAmp if so check that all the required extensions are activated in there as well as the php.ini used by your web server - RiggsFolly
Check if php-mysql is installed on your server - Preciel
@RiggsFolly i have add my php.ini on my post. I have the extension pdo_mysql. - user9801655
@Preciel i use UwAmp on Windows, not Linux. - user9801655
Right: But as I said in my previous comment. Some systems have 2 php.ini files. One is used by the PHP under Apache and the other is used by PHP CLI (Command Line Interface) Look in the folder containing PHP and see if there is a php.ini in that folder. That will be the one used by the CLI - RiggsFolly

5 Answers

3
votes

This works for my case

symfony 4.2
php 7.3

I enabled

extension=pdo_mysql

in php.ini

1
votes

RiggsFolly brought the solution :

I have a second php.ini file in UwAmp. The extension pdo_mysql was disabled in bin/php/php-version/php.ini

1
votes
in file=> config\packages\doctrine.yaml

dbal:
        dbname:               database
        host:                 localhost
        port:                 1234
        user:                 user
        password:             secret
        driver:               pdo_mysql
        # if the url option is specified, it will override the above config
        url:                  mysql://db_user:[email protected]:3306/db_name
        # the DBAL driverClass option
        driver_class:         App\DBAL\MyDatabaseDriver
0
votes

I have just installed UwAmp 3.1.0 on a Windows 10 machine, and faced this same issue when trying to run the php artisan migrate command on a Laravel app. Here's how I solved it:

  • Go to bin/php/<php-version>
  • Make a copy of php_uwamp.ini named php-cli.ini
  • Open it on a text editor
  • Replace extension_dir = "{PHPEXTPATH}" by extension_dir = "ext"
  • Replace zend_extension = "{PHPZENDPATH}/php_xdebug.dll" by extension_dir = "../zend_ext/php_xdebug.dll"

Every time you change PHP Config on UwAmp interface, you must repeat these steps, since the changes are stored on php_uwamp.ini.

0
votes

in the file php.ini there is the extension extension=pdo_mysql that is disabled. I enabled it and the connection worked.