简体   繁体   English

使用Delphi 2010和php4Delphi编写PHP扩展

[英]Writing PHP extensions using Delphi 2010 and php4Delphi

Firstly this is about php4Delphi not RadPHP (formerly Delphi For PHP). 首先这是关于php4Delphi而不是RadPHP (以前的Delphi For PHP)。

Using 运用

  • Delphi 2010 Delphi 2010
  • PHP 5.3.6 (VC9, NTS) PHP 5.3.6(VC9,NTS)
  • php4Delphi 7.2 (compiled with VC9 directive) php4Delphi 7.2(用VC9指令编译)
  • Windows Server 2008 R2 Windows Server 2008 R2
  • IIS 7 IIS 7

When trying to run the php4Delphi delphi_math.dll example extension on the IIS/PHP server I see the following error in the C:\\Windows\\Temp\\php-errors.log file. 当试图在IIS / PHP服务器上运行php4Delphi delphi_math.dll示例扩展时,我在C:\\ Windows \\ Temp \\ php-errors.log文件中看到以下错误。

[15-Jun-2011 17:58:42] PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\Program Files (x86)\\PHP\\ext\\delphi_math.dll' - A dynamic link library (DLL) initialization routine failed. [15-Jun-2011 17:58:42] PHP警告:PHP启动:无法加载动态库'C:\\ Program Files(x86)\\ PHP \\ ext \\ delphi_math.dll' - 动态链接库(DLL)初始化例行失败。 in Unknown on line 0 在第0行的未知中

I've already resolved the initial issue of PHP not finding my extension so it's not a path style problem. 我已经解决了PHP的初始问题,没有找到我的扩展,因此它不是路径样式问题。

I'm thinking that php4Delphi 7.2 may not support the latest PHP 5.3.6. 我认为php4Delphi 7.2可能不支持最新的PHP 5.3.6。 Has anyone got this configuration working for them? 有谁有这个配置为他们工作?

PHP tries to load the module internally and fails, you are right. PHP尝试在内部加载模块并失败,你是对的。

The problem is not in the search path, but in the usage of the not thread safe version of php with php4delphi. 问题不在于搜索路径,而在于使用php4delphi的非线程安全版本的php。 When php loads an extension it receives the list of some call-back functions from the extension dll and use it for communicating with dll. 当php加载扩展时,它从扩展dll接收一些回调函数的列表,并用它与dll进行通信。 The list of the parameters of the callback function for thread safe and not thread safe versions of php is different. 用于线程安全而不是线程安全版本的php的回调函数的参数列表是不同的。

php4delphi was made for thread safe model of php. php4delphi是为php的线程安全模型而制作的。 You can read what is the difference between TS and NTS versions here: IIS Aid . 您可以在此处阅读TS和NTS版本之间的区别: IIS Aid In this particular case I would recommend to change the not thread safe PHP to thread safe PHP, if possible. 在这种特殊情况下,如果可能的话,我建议将非线程安全的PHP更改为线程安全的PHP。

If the usage of NTS PHP is a requirement, then the source code of php4delphi must be adapted and I think in this case a lot of changes are needed. 如果需要使用NTS PHP,那么必须调整php4delphi的源代码,我认为在这种情况下需要进行大量更改。

I just did the test of php4delphi 7.2 with PHP 5.3.6, but the thread-safe version and the extension was loaded as expected. 我刚刚用PHP 5.3.6测试了php4delphi 7.2,但线程安全版本和扩展名按预期加载。 I think you can use NTS version only if you run your script using php.exe from the command line, not when you use IIS. 我认为只有在从命令行使用php.exe运行脚本时才能使用NTS版本,而不是在使用IIS时。 Anyway, I will do the test with NTS version as well and let you know about the result. 无论如何,我也会用NTS版本进行测试,让你知道结果。

To me it looks like PHP itself (and not delphiphp) tries to load a module internally and that fails. 对我来说,看起来PHP本身(而不是delphiphp)试图在内部加载模块而失败。

It could be that it searches for DLLs in the PATH to loadlibrary() but finds 64-bit DLLs instead of 32-bit DLLs. 它可能是它在PATH中搜索DLL到loadlibrary()但找到64位DLL而不是32位DLL。 Best first try this setup on a 32-bit Windows system. 最好先在32位Windows系统上尝试此设置。

Ps the 64-bit system indication I get from "program files (x86)" obviously Ps显然是从“程序文件(x86)”得到的64位系统指示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM