Howto use same extension on different PHP5 versions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
harrym
Forum Newbie
Posts: 7
Joined: Thu Oct 29, 2009 11:01 am

Howto use same extension on different PHP5 versions

Post by harrym »

Hi,

I'm have created an extension for PHP5 in Windows.
My problem is that the installed version of PHP5 must match exactly the source against which my extension was compiled,
or my extension is not loaded at all.

It seems to me that this means that I must have exactly as many extensions compiled as there are PHP5 versions,
even if if I'm quite sure that the same extension dll should work on other PHP5 versions than the one it was compiled on.

Is there a way in PHP5 to disable the very strict version checks, even if just for testing?

Thanks in advance.
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: Howto use same extension on different PHP5 versions

Post by markusn00b »

harrym wrote:Hi,

I'm have created an extension for PHP5 in Windows.
My problem is that the installed version of PHP5 must match exactly the source against which my extension was compiled,
or my extension is not loaded at all.

It seems to me that this means that I must have exactly as many extensions compiled as there are PHP5 versions,
even if if I'm quite sure that the same extension dll should work on other PHP5 versions than the one it was compiled on.

Is there a way in PHP5 to disable the very strict version checks, even if just for testing?

Thanks in advance.
Compile your extension under PHP4 - just like you do for PHP5.

However, ZE1 (Zend Engine 1) differs quite a lot from ZE2, so you may encounter some difficulty geting an extension written under ZE2 (PHP5) to compile for ZE1 (PHP4). As far as I can recall, ZE2 does provide BC (backwards compatibility) for extensions developed under ZE1, but I doubt you can get ZE2 extensions to work (easily) with ZE1.

Mark.
harrym
Forum Newbie
Posts: 7
Joined: Thu Oct 29, 2009 11:01 am

Re: Howto use same extension on different PHP5 versions

Post by harrym »

For some reason I can't use an extension compiled on 5.3.0 on 5.2.9.
Is that normal?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Howto use same extension on different PHP5 versions

Post by requinix »

harrym wrote:For some reason I can't use an extension compiled on 5.3.0 on 5.2.9.
Is that normal?
Yes. 5.3 is very different from 5.2. It resembles PHP 6 more than it does PHP 5.
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: Howto use same extension on different PHP5 versions

Post by markusn00b »

harrym wrote:For some reason I can't use an extension compiled on 5.3.0 on 5.2.9.
Is that normal?
Much for the same reasons I mentioned before - an extension compiled on PHPx will not work for PHP<x.
harrym
Forum Newbie
Posts: 7
Joined: Thu Oct 29, 2009 11:01 am

Re: Howto use same extension on different PHP5 versions

Post by harrym »

Thanks for the answer - I now start seeing the light. PHPx and higher is workable!

So let me ask the opposite question: If I compile with PHP5.0, will it work for all 5.x?
Or which is the lowest PHP5.y which will work with 5.3 and 5.2.

And the same question for PHP4 (or I may restrict the extension to PHP5).
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: Howto use same extension on different PHP5 versions

Post by markusn00b »

harrym wrote:Thanks for the answer - I now start seeing the light. PHPx and higher is workable!

So let me ask the opposite question: If I compile with PHP5.0, will it work for all 5.x?
Or which is the lowest PHP5.y which will work with 5.3 and 5.2.

And the same question for PHP4 (or I may restrict the extension to PHP5).
In fact, after talking to the PHP developers, for example, an extension compiled on 5.2.0 will only work on the 5.2.x range of releases. The minor version is increased when a binary incompatibility exists, hence why you cannot compile on a newer/older build.

This is generally why we provide the source code, makefiles, etc., to the user so they can build the extension on their PHP.
harrym
Forum Newbie
Posts: 7
Joined: Thu Oct 29, 2009 11:01 am

Re: Howto use same extension on different PHP5 versions

Post by harrym »

This is a big problems for us developers - the too strict version check.

Under Windows we have:
2 compilers : VC6 & VC9
x versions : 5.0 5.1 5.2 5.3 4.4 4.3 4.2 4.1 4.0 (let's stop here) = 9 versions
2 flavors : Release and Debug.
That's assuming we restrict ourselves to the TS version.
Total : 2 x 9 x 2 = 36 (!)

Now just try and calculate the amount of time spent on maintaining all these versions.
And all this just for Windows. We haven't yet tried to port to Linux.

This multiplicity of versions is very simply unmanageable.
My company is not large, and what we're finding out about the maintenance costs
of furnishing a PHP extension is really very very frightening.
Post Reply