Symfony 4 MSSQL sqlsrv:找不到驱动程序
Symfony 4 MSSQL sqlsrv: could not find driver
我想将我的项目升级到 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显示可以找到驱动
[更新]
Web 应用程序显示更清晰的错误。出于某种原因,它正在加载某种默认设置。
尝试将此配置用于主义,检查the doctrine config reference
doctrine:
dbal:
connections:
default:
driver: sqlsrv
url: '%env(resolve:DATABASE_URL)%'
我添加了 sqlsrv(你说你已经安装了它)而不是 pdo_sqlsrv 作为 it causes problems。
我想将我的项目升级到 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显示可以找到驱动
[更新]
Web 应用程序显示更清晰的错误。出于某种原因,它正在加载某种默认设置。
尝试将此配置用于主义,检查the doctrine config reference
doctrine:
dbal:
connections:
default:
driver: sqlsrv
url: '%env(resolve:DATABASE_URL)%'
我添加了 sqlsrv(你说你已经安装了它)而不是 pdo_sqlsrv 作为 it causes problems。