Dead C Scrolls - Missing Code for Writing New Extensions without recompiling PHP

php.internals

Andrew Mather

20 years ago
My thanks to the contributors and for the resource documentation that: a) has confirmed that writing extensions without recompiling PHP is possible b) have provided sample code that requires recompilation of PHP As a Linux newbie but experienced Windows programmer I do not have the arcane knowledge to infer from the recompile-PHP sample how to modify it to generate a must-recompile-php sample to a standalone extension. I haven't used make in twenty years, and autoconf is alien to me. I am getting to grips with .so (shared object) libraries in Unix, but I am in the dark and my effort would be greatly expedited by someone knowledgeable in the art. I therefore re-interate my request for a complete walkthrough for writing an extension that does not require recompilation of php but can be treated as a simple external standalone project, for later inclusion into the Apache/PHP module by dynamic linking. I have installed and am running Suse 9.3, with Apache 2.0 and Php 5, all from the Suse distribution. I have downloaded the source for Php 5.1.1, but while I have compiled such (in the course of the build-extension-with-recompile) I do not wish to rely on having to recompile PHP every time I wish to build an extension. I have not therefore attempted to replace the distribution-Php with the compiled-Php. At this point, my need for such assistance is critical, as a client project is stalled for lack of it. I appreciate that money is a dirty word in Linux, but time and money are being wasted for want of these answers, so that I would be more than happy to provide £100 for the first proven and effective replies in each of these categories (all of which may happily be 'scooped' by or paid to a single person): i) a walkthrough of the exact steps + sample code to write an extension without requiring re-compilation of Php and without access to Php source code ii) as above but with access to Php source code iii) as above (either i or ii) but with instructions to allow the project to be initiated and compiled within the KDE development environment Resulting object (presumably .so) to be accessible in a distribution release of Apache/Php with only minor modification of a client's Apache/Php config settings.

George Schlossnagle

20 years ago
Andrew Mather wrote:
>i) a walkthrough of the exact steps + sample code to write an extension without > requiring re-compilation of Php and without access to Php source code > > >ii) as above but with access to Php source code > >
You're clearly missing the -devel RPM that installs the necessary header files to allow you to build extensions outside of a source tree. That devel rpm will install the phpize and php-config executables, and a set of headers under the appropriate destination for your distro (I'm not a SuSE user, but I would expect them to be either under /usr/include/php or /usr/local/include/php). If you don't have these then you need to get the RPM that provides them (php-devel or something along those lines) before you can move forward. Look at practically any extension in PECL and read it's INSTALL instructions. For instance, look at APC and read it's INSTALL file. Again, without the -devel RPM that provides your necessary headers you will be up th creek.
>iii) as above (either i or ii) but with instructions to allow the project to be initiated > and compiled within the KDE development environment > >
That shouldn't make any difference. George

Sara Golemon

20 years ago
> a) has confirmed that writing extensions without recompiling PHP is > possible > b) have provided sample code that requires recompilation of PHP >
The only code that *requires* recompiling PHP is something which patches the core or the engine. Simple extensions don't do this. Certainly not the "hello world" examples you're asking for. The *suggestion* in http://www.zend.com/php/internals/ to recompile PHP with --enable-debug and --enable-maintainer-zts is aimed at making development easier and less prone to problems.
> As a Linux newbie but experienced Windows programmer I do not have > the arcane knowledge to infer from the recompile-PHP sample how to > modify it to generate a must-recompile-php sample to a standalone > extension. >
None of the samples provided are "must-recompile", you're mistaken.
> I am getting to grips with .so (shared object) libraries in Unix, but I am > in the > dark and my effort would be greatly expedited by someone knowledgeable > in the art. >
They're no different that DLLs, don't let the name scare you.
> I therefore re-interate my request for a complete walkthrough for writing > an extension that does not require recompilation of php but can be treated > as a simple external standalone project, for later inclusion into the > Apache/PHP > module by dynamic linking. >
http://www.zend.com/php/internals/ If you followed the instructions you wound up with a shared module.
> I have installed and am running Suse 9.3, with Apache 2.0 and Php 5, all > from the Suse distribution. I have downloaded the source for Php 5.1.1, > but while > I have compiled such (in the course of the build-extension-with-recompile) > I do not > wish to rely on having to recompile PHP every time I wish to build an > extension. >
Nor do you. You're asking for the voice of experience to tell you how you should be designing new extensions. That voice is saying "Setup a proper build environment". A proper build environment means recompiling PHP *ONCE* to make sure you have all the tools available in all the right places. Once you have those tools in place you can bulid your extensions are stand-alone shared objects by following instructions.
> I have not therefore attempted to replace the distribution-Php with the > compiled-Php. >
Your loss.
> At this point, my need for such assistance is critical, as a client > project is stalled for lack of it. > I appreciate that money is a dirty word in Linux, but time and money are > being wasted > for want of these answers, so that I would be more than happy to provide > £100 for the > first proven and effective replies in each of these categories (all of > which may happily > be 'scooped' by or paid to a single person): >
I don't want your money. The anger and petulance you've shown while asking for "help" is an embarrasment to the community.
> i) a walkthrough of the exact steps + sample code to write an extension > without > requiring re-compilation of Php and without access to Php source code > ii) as above but with access to Php source code > iii) as above (either i or ii) but with instructions to allow the project > to be initiated > and compiled within the KDE development environment > >Resulting object (presumably .so) to be accessible in a distribution >release of Apache/Php > with only minor modification of a client's Apache/Php config settings. >
http://www.zend.com/php/internals/ Get rid of your incorrect assumptions and read it again. Everything you asked for is there. -Sara

Hartmut Holzgraefe

20 years ago
Andrew Mather wrote:
> i) a walkthrough of the exact steps + sample code to write an extension without > requiring re-compilation of Php and without access to Php source code
maybe its time for a shameless plug one more time: http://pear.php.net/package/CodeGen_PECL/docs this approach will shield you from autoconf/make details as much as possible, it will also generate windows VS 6.0 .dsp project files, too
> ii) as above but with access to Php source code
its not mentioned in the above docs, but compiling the generated extension code staticly into PHP just requires these simple steps: - place the generated code directory into PHPs ext/ directory - run buildconf (in the top level src directory) - if you've already built php from this source tree before do config.nice ...any-options-specific-to-your-extension else extract the configure string for the current php installation from "php -i" output, re-use this configure line and add your extensions options to it - make - optional: make test - make install (may require sudo)
> iii) as above (either i or ii) but with instructions to allow the project to be initiated > and compiled within the KDE development environment
i don't know / use Kdevelop, but i'm pretty sure that it allows to integrate standard unix projects based on configure/make ...
> Resulting object (presumably .so) to be accessible in a distribution release of Apache/Php > with only minor modification of a client's Apache/Php config settings.
using CodeGen_PECL you'll get a full self contained extension project, including a package.xml file suitable for automatic installation using the pear installer
-- Hartmut Holzgraefe, Senior Support Engineer . MySQL AB, www.mysql.com

Steph

20 years ago
Ouf, Hartmut, does it make 'the new win32 build system' config files too? /me hasn't tried, just wants to know... ----- Original Message ----- From: "Hartmut Holzgraefe" <hartmut@php.net> To: "Andrew Mather" <an.dromeda@btconnect.com> Cc: <internals@lists.php.net> Sent: Friday, February 10, 2006 8:01 PM Subject: Re: [PHP-DEV] Dead C Scrolls - Missing Code for Writing New Extensionswithout recompiling PHP