英文:
Getting PHP working with MS Sql on Windows with VS2022 and IIS Express
问题
我试图从Visual Studio 2022的网页中使用PHP Tools for Visual Studio 2022(来自DEVSENSE)在IIS Express和VS 2022调试中使一个简单的和示例的数据库查询工作。
我知道基本的PHP安装是有效的,因为我可以运行一个脚本
<?php
phpinfo();
?>
并将报告转储到一个网页中。
然而,我似乎无法让MS SQL的PDO驱动程序加载DLL并显示在报告中。
我已经添加和修改了位于C:\Program Files\IIS Express\PHP\v8.2\ext中的php.ini文件中的适当行。
已经尝试重新启动VS以便重新启动IIS Express,
\[ExtensionList\]
extension=php_pdo_mysql.dll
extension=php_pdo_sqlite.dll
extension=php_pdo_sqlsrv_81_ts_x64.dllextension=php_pdo_sqlite.dll
extension=php_pdo_sqlsrv_81_ts_x64.dll
来自phpinfo()的结果;
PHP Version 8.2.1
System Windows NT JEFFMU-XPS13-32 10.0 build 22621 (Windows 11) AMD64
Build Date Jan 3 2023 23:31:42
Build System Microsoft Windows Server 2019 Datacenter \[10.0.17763\]
Compiler Visual C++ 2019
Architecture x64
Configure Command cscript /nologo /e:jscript configure.js "--enable-snapshot-build" "--enable-debug-pack" "--disable-zts" "--with-pdo-oci=........\\instantclient\\sdk,shared" "--with-oci8-19=........\\instantclient\\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--without-analyzer" "--with-pgo"
Server API Built-in HTTP server
Virtual Directory Support disabled
Configuration File (php.ini) Path no value
Loaded Configuration File C:\\Program Files\\IIS Express\\PHP\\v8.2\\php.ini
PDO
PDO support enabled
PDO drivers mysql, sqlite
英文:
I am trying to get a simple and sample database query working from a webpage in Visual Studio 2022 with PHP Tools for Visual Studio 2022 from DEVSENSE with IIS Express and VS 2022 debug.
I know the base PHP install is working because I can run a script
<?php
phpinfo();
?>
And get the report dumped to a web page.
However, I can’t seem to get the PDO driver for MS SQL to load DLL and show up in the report.
I have added and modified the appropriate lines in php.ini file located in C:\Program Files\IIS Express\PHP\v8.2\ext
Have retried restarting VS so that IIS Express gets restarted,
\[ExtensionList\]
extension=php_pdo_mysql.dll
extension=php_pdo_sqlite.dll
extension=php_pdo_sqlsrv_81_ts_x64.dllextension=php_pdo_sqlite.dll
extension=php_pdo_sqlsrv_81_ts_x64.dll
Results from phpinfo();
PHP Version 8.2.1
System Windows NT JEFFMU-XPS13-32 10.0 build 22621 (Windows 11) AMD64
Build Date Jan 3 2023 23:31:42
Build System Microsoft Windows Server 2019 Datacenter \[10.0.17763\]
Compiler Visual C++ 2019
Architecture x64
Configure Command cscript /nologo /e:jscript configure.js "--enable-snapshot-build" "--enable-debug-pack" "--disable-zts" "--with-pdo-oci=........\\instantclient\\sdk,shared" "--with-oci8-19=........\\instantclient\\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--without-analyzer" "--with-pgo"
Server API Built-in HTTP server
Virtual Directory Support disabled
Configuration File (php.ini) Path no value
Loaded Configuration File C:\\Program Files\\IIS Express\\PHP\\v8.2\\php.ini
PDO
PDO support enabled
PDO drivers mysql, sqlite
答案1
得分: 2
不确定您是按照哪篇文章进行设置的,但使用php_pdo_sqlsrv_81_*.dll
是错误的。
PHP 8.2需要来自Microsoft GitHub存储库的最新SQL Server驱动程序文件。现在您只能从5.11.0中下载“Windows-8.2.zip”,因为它添加了对PHP 8.2的支持。所有先前的版本都不支持PHP 8.2。
ZIP包中的文件是php_pdo_sqlsrv_82_*.dll
,供您参考。
参考
- https://github.com/microsoft/msphpsql/releases/tag/v5.11.0
- https://github.com/microsoft/msphpsql/issues/1420
英文:
Not sure which article you followed to perform the setup, but it is wrong to use php_pdo_sqlsrv_81_*.dll
.
PHP 8.2 requires up-to-date SQL Server driver files from Microsoft GitHub repo. And right now you can only download "Windows-8.2.zip" from 5.11.0 as it added PHP 8.2 support. All previous releases do not support PHP 8.2.
The files from the ZIP package are php_pdo_sqlsrv_82_*.dll
for your reference.
Reference
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论