PHP扩展的API号码不同 [英] Different API number for PHP extension
问题描述
问题是,我的客户是使用不同的php服务器与不同的API肯定,我打算给他们一个dll(我的扩展),可以很容易地加载,没有任何的斗争。但现在我应该给他们一个VS2010解决方案,我的主要代码(dll)动态加载。我的意思是每个用户应该首先从他自己的服务器检查PHP API,并更改Zend_modules.h头文件,构建解决方案,然后使用扩展名。我需要一个解决方案,使我的扩展完全独立于该API号码。
我真的很感激任何想法。
我完全理解错误,所以我在php源中打开Zend_modules.h头文件并将API号码从20090626更改为20100525
你这样做的事实告诉我你实际上并不了解错误
模块在不同主要版本的PHP之间兼容不 - Zend API号码用于确保PHP不会无意中尝试加载为不同版本构建的模块。您对PHP构建树的修改正在导致它构建在任何版本上都无法正常运行的模块。
如果需要构建模块对于PHP的多个主要版本,您需要使用相应版本的PHP运行构建。您不能混合和匹配,您不能构建将适用于多个版本的单个模块。 (也不应该建议您的用户修改他们的PHP版本以接受一个不兼容的模块,这只会使可怕的事情发生。)
几个版本的API版本的PHP列出如下:
- PHP 5.2:20060613
- PHP 5.3:20090626
- PHP 5.4:20100525
- PHP 5.5:20120211
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.
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
这篇关于PHP扩展的API号码不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!