Getting PHP working with MS Sql on Windows with VS2022 and IIS Express

huangapple go评论86阅读模式
英文:

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安装是有效的,因为我可以运行一个脚本

  1. <?php
  2. phpinfo();
  3. ?>

并将报告转储到一个网页中。
然而,我似乎无法让MS SQL的PDO驱动程序加载DLL并显示在报告中。

我已经添加和修改了位于C:\Program Files\IIS Express\PHP\v8.2\ext中的php.ini文件中的适当行。
已经尝试重新启动VS以便重新启动IIS Express,

  1. \[ExtensionList\]
  2. extension=php_pdo_mysql.dll
  3. extension=php_pdo_sqlite.dll
  4. extension=php_pdo_sqlsrv_81_ts_x64.dllextension=php_pdo_sqlite.dll
  5. extension=php_pdo_sqlsrv_81_ts_x64.dll

来自phpinfo()的结果;

  1. PHP Version 8.2.1
  2. System Windows NT JEFFMU-XPS13-32 10.0 build 22621 (Windows 11) AMD64
  3. Build Date Jan 3 2023 23:31:42
  4. Build System Microsoft Windows Server 2019 Datacenter \[10.0.17763\]
  5. Compiler Visual C++ 2019
  6. Architecture x64
  7. 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"
  8. Server API Built-in HTTP server
  9. Virtual Directory Support disabled
  10. Configuration File (php.ini) Path no value
  11. Loaded Configuration File C:\\Program Files\\IIS Express\\PHP\\v8.2\\php.ini
  12. PDO
  13. PDO support enabled
  14. 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

  1. <?php
  2. phpinfo();
  3. ?>

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,

  1. \[ExtensionList\]
  2. extension=php_pdo_mysql.dll
  3. extension=php_pdo_sqlite.dll
  4. extension=php_pdo_sqlsrv_81_ts_x64.dllextension=php_pdo_sqlite.dll
  5. extension=php_pdo_sqlsrv_81_ts_x64.dll

Results from phpinfo();

  1. PHP Version 8.2.1
  2. System Windows NT JEFFMU-XPS13-32 10.0 build 22621 (Windows 11) AMD64
  3. Build Date Jan 3 2023 23:31:42
  4. Build System Microsoft Windows Server 2019 Datacenter \[10.0.17763\]
  5. Compiler Visual C++ 2019
  6. Architecture x64
  7. 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"
  8. Server API Built-in HTTP server
  9. Virtual Directory Support disabled
  10. Configuration File (php.ini) Path no value
  11. Loaded Configuration File C:\\Program Files\\IIS Express\\PHP\\v8.2\\php.ini
  12. PDO
  13. PDO support enabled
  14. 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,供您参考。

参考

英文:

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

huangapple
  • 本文由 发表于 2023年3月7日 09:02:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75657189.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定