驱动程序中发生异常:找不到驱动程序绑定来创建基于理论的数据库

时间:2019-04-21 17:29:26

标签: php symfony doctrine-orm

我已执行

 php bin/console doctrine:database:create

创建项目的datbabase,我收到此错误

Failed loading /opt/lampp/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so:  /opt/lampp/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so: cannot open shared object file: No such file or directory

In AbstractMySQLDriver.php line 115:

  An exception occured in driver: could not find driver  


In PDOConnection.php line 47:

  could not find driver  


In PDOConnection.php line 43:

  could not find driver  

我在ubuntu上使用xampp,这是symfony的配置文件

 # This file is auto-generated during the composer install
parameters:
    database_host: 127.0.0.1
    database_port: 3306
    database_name: mydb
    database_user: root
    database_password: 12345
    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_user: null
    mailer_password: null
    secret: 55c7fcc15002180af1c4f7ad79dc62cfe6dfd91e

我不知道怎么了

1 个答案:

答案 0 :(得分:1)

我认为驱动程序未在您的参数中配置,因此让我们添加它为:

parameters:
    database_driver: pdo_mysql # <== you can change it in your driver database
    database_host: 127.0.0.1
    database_port: 3306
    database_name: mydb
    database_user: root
    database_password: 12345
    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_user: null
    mailer_password: null
    secret: 55c7fcc15002180af1c4f7ad79dc62cfe6dfd91e

注意:您可以像这样检查终端中所有可用的驱动程序:

php -m

并且通常它必须向您显示所需的扩展驱动程序,如:

.......
PDO
pdo_dblib
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
.......

谢谢,希望对您有帮助