Different API number for PHP extension

那年仲夏 提交于 2019-12-23 04:52:48

问题


So this is the case, I am trying to develop an php-extension for my customers. I use SWIG for generating the wrapper code and my main code is c++. After I create my extension successfully I load it in /ext and restart the web server for testing it. I've got the error which mentioned that the extension has been built with API 20090626 but the PHP server(in my case XAMPP) API is 20100525. I totally understand the error, so I open the Zend_modules.h header file in php source and change the API number from 20090626 to 20100525, then I build my extension with updated zend_modules.h header file and now I have no problem.

The question is, my customers are using different php servers with different APIs for sure, and I planed to give them a dll (my extension) which can be loaded easily without any struggles. But now I should give them a VS2010 solution with my main code (dll) dynamically loaded. I mean each user should first check the PHP API from his own server and change the Zend_modules.h header file, build the solution and then use the extension. I need a solution which make my extension totally independent to that API number.

I really appreciate any idea.


回答1:


I totally understand the error, so I open the Zend_modules.h header file in php source and change the API number from 20090626 to 20100525

The fact that you're doing this tells me that you do not actually understand the error.

Modules are NOT compatible between different major versions of PHP -- the Zend API number is used to ensure that PHP does not inadvertently attempt to load a module that was built for a different version. The modifications that you're making to your PHP build tree are causing it to build modules that will not function correctly on any version at all.

If you need to build modules for multiple major versions of PHP, you need to run the builds using the corresponding version of PHP. You cannot mix and match, and you cannot build a single module that will work for multiple versions. (Nor should you advise your users to modify their PHP build to accept an incompatible module. That'll just make horrible things happen.)

The API versions for a few versions of PHP are listed below:

  • PHP 5.2: 20060613
  • PHP 5.3: 20090626
  • PHP 5.4: 20100525
  • PHP 5.5: 20120211


来源:https://stackoverflow.com/questions/15171059/different-api-number-for-php-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!