如何构建在许多PHP版本中运行的PHP扩展? [英] How to build a PHP extension that runs in many PHP versions?

查看:198
本文介绍了如何构建在许多PHP版本中运行的PHP扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C ++创建了一个PHP扩展。我想把我的扩展名以我的客户端的二进制形式。这意味着我需要为每个PHP版本(5.2,5.3,5.4,5.5)和每个处理器体系结构构建一个单独的版本。



我的问题是:


  1. API时间戳,而API本身似乎没有改变?它不会删除很多头痛,同时升级您的系统,以使用下一个版本的PHP?为了比较,我还有一个版本的我的扩展MS Excel使用XLL API和该API自2003年以来一直向后兼容,这允许我只有两个二进制文件(32和64位)为所有的客户端。 p>


  2. 有什么办法解决这个问题吗?也就是说有没有办法构建一个可以在多个PHP版本中运行的PHP扩展?



解决方案

也许你可以尝试混合方法。单独编译您的C ++库,然后创建一个开源的PHP扩展包装。 PHP扩展几乎没有自己的逻辑。它会将数据类型从PHP转换为C / C ++,并将参数传递给C ++库中实现的函数/方法。



您的库每个平台和采用一个特定的PHP版本是由开源PHP扩展。



这当然要求您的客户的系统有PHP开发包以及编译器。


I have created a PHP extension using C++. I want to ship my extension to my clients in its binary form. That means I need to build a separate version of it for each PHP version (5.2, 5.3, 5.4, 5.5) and each processor architecture.

My questions are:

  1. why do they keep updating the API timestamp while the API itself seemingly does not change? Wouldn't it remove a lot of headache while upgrading your system to use the next version of PHP? Just for comparison, I also have a version of my extension for MS Excel using the XLL API and that API has remained backwards compatible since 2003 which allows me to have just two binaries (32 and 64 bit) for all of my clients.

  2. Is there any way around this problem? I.e. is there a way to build a PHP extension that can be run in multiple PHP versions?

解决方案

Maybe you can try a hybrid approach. Compile your C++ library separately and then create an open source PHP extension wrapper for that. The PHP extension has nearly no logic of its own. It converts data types from PHP to C/C++ back and forth and passes the arguments to functions/methods implemented in your C++ library.

You then just maintain a binary version of your library per platform and the adoption to a particular PHP version is done by the open source PHP extension.

This of course requires that the systems of your customers do have the PHP development packages installed, as well as a compiler.

这篇关于如何构建在许多PHP版本中运行的PHP扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆