Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Writing PHP extensions using Delphi 2010 and php4Delphi

Firstly this is about php4Delphi not RadPHP (formerly Delphi For PHP).

Using

  • Delphi 2010
  • PHP 5.3.6 (VC9, NTS)
  • php4Delphi 7.2 (compiled with VC9 directive)
  • Windows Server 2008 R2
  • 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.

[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. in Unknown on line 0

I've already resolved the initial issue of PHP not finding my extension so it's not a path style problem.

I'm thinking that php4Delphi 7.2 may not support the latest PHP 5.3.6. Has anyone got this configuration working for them?

like image 906
LachlanG Avatar asked Jun 15 '11 08:06

LachlanG


1 Answers

PHP tries to load the module internally and fails, you are right.

The problem is not in the search path, but in the usage of the not thread safe version of php with php4delphi. 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. The list of the parameters of the callback function for thread safe and not thread safe versions of php is different.

php4delphi was made for thread safe model of php. You can read what is the difference between TS and NTS versions here: IIS Aid. In this particular case I would recommend to change the not thread safe PHP to thread safe PHP, if possible.

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.

like image 81
Perevoznyk Avatar answered Nov 14 '22 22:11

Perevoznyk