我想将我的项目升级到symfony 4,但是该学说似乎找不到找到我的数据库所需的mssql驱动程序。
$ php bin/console doctrine:database:create --env=dev
In AbstractMySQLDriver.php line 125:
An exception occurred in driver: could not find driver
突出的是MySQLDriver.php中出现错误的事实,而我明确地告诉symfony我想使用sqlsrv驱动程序。
这些是我的doctrine.yaml设置:
parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
env(DATABASE_URL): 'sqlsrv://my_user:my_password@my_host/my_dbname'
doctrine:
dbal:
# configure these for your database server
driver: 'sqlsrv'
host: 'my_host'
user: 'my_user'
password: 'my_password'
dbname: 'my_dbname'
port: 'null'
#server_version: '5.7'
#charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
url: '%env(resolve:DATABASE_URL)%'
phpinfo显示可以找到驱动程序
[更新]
webapp显示更明确的错误。出于某种原因,它加载了某种默认设置。
答案 0 :(得分:2)
尝试将此配置用于学说,请检查the doctrine config referenc e
doctrine:
dbal:
connections:
default:
driver: sqlsrv
url: '%env(resolve:DATABASE_URL)%'
我添加了 sqlsrv (您说已经安装了它)而不是 pdo_sqlsrv 作为it causes problems。