You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel连接SQL Server提示'could not find driver'问题求助

Laravel连接SQL Server提示'could not find driver'问题求助

我刚装好SQL Server实例,普通的数据库连接都能正常工作,但在Laravel项目里运行php artisan serve启动本地服务时,却弹出了“could not find driver”的错误提示。

具体错误信息如下:

Illuminate
\
Database
\
QueryException
PHP 8.2.15
11.0.8
could not find driver
SELECT
  top 1 *
FROM
  [ sessions ]
WHERE
  [ id ] = FnziuCl4Bh7mfDbUW4F3E0OQKfryNLEd21vPSyF3

我检查了php.ini文件,确认SQL Server扩展已经启用了:

sqlsrv
sqlsrv support  enabled
ExtensionVer    5.11.1+17301
Directive   Local Value Master Value
sqlsrv.ClientBufferMaxKBSize    10240   10240
sqlsrv.LogSeverity  0   0
sqlsrv.LogSubsystems    0   0
sqlsrv.WarningsReturnAsErrors   On  On

我的**.env**数据库配置是这样的:

DB_CONNECTION=sqlsrv
DB_HOST=192.168.xx.xx
DB_PORT=1433
DB_DATABASE=webdev_laravel
DB_USERNAME=webdev_applikation
DB_PASSWORD=password

我已经尝试过以下操作,但问题依然存在:

  • 重启服务器
  • 清除项目缓存

我查阅了很多有相同错误的讨论帖,但我不想使用PDO,而且我觉得PDO是可选的组件,是不是这样?

备注:内容来源于stack exchange,提问作者Likemike90

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.17 12:33:02