Jump to content

Building PHP Extensions


deendee

Recommended Posts

SCENARIO: I've used PHP extensively BUT am very new to extending it. However I've quickly got to get PHP 4.3.x
talking to a certain C/C++ application that I am building for AI routines. I've also checked out a lot of "Building Custom PHP Extensions" tutorials, even the manual at [a href=\"http://www.php.net/manual/en/zend.php\" target=\"_blank\"]http://www.php.net/manual/en/zend.php[/a] and liked them much. HOWEVER they deviate from
what am looking for. Actually, what I see described @ [a href=\"http://www.zend.com/php/internals/extension-writing1.php\" target=\"_blank\"]http://www.zend.com/php/internals/extension-writing1.php[/a] appears like she's building certain functionality into PHP (I guess that's only half of how one can extend PHP) rather than get PHP to use functionality from an external
program - much like interfacing it with MySQL or GD etc. I wish she was describing the latter method rather than the former.

QUESTION: How then do I interface PHP with the C/C++ program without duplicating the AI effort into the PHP loadable
module? Please advice
Link to comment
Share on other sites

Im no expert here, but I assume it just depends on the API provided by the AI application.

If its a working stand allone application, it might be just as easy to use exec() or system() to use its functionality within php.

Your best bet is probably to download the php source and check out one of the smaller extensions. sqlite seems a fairly tidy extension with a nice clear API, I'de go from there.
Link to comment
Share on other sites

  • 4 weeks later...
I'd like to know more about this myself.

I'd like to use php as a sort of scripting engine in a native c/c++ executable, just to allow users to dynamically change a buffer's contents (nothing to do with web services).

[input]->[php4ts.dll]->[output]
...............<script>

In other words, the php dll would run the selected script, modify the text buffer, and return the modified contents to the main app. End users would write the script to use in processing the text, according to their needs.

Here's what I've found so far:

Raydium game engine uses php for scripting (open src, google it, I don't have the url)
There's also a wrapper called SWIG that might be of use, maybe.
Check both the PEAR and PECL extension repositories if you haven't already.

I'm just getting started, so don't have any definitive results yet.


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.