Jump to content


Photo

Building PHP Extensions


  • Please log in to reply
2 replies to this topic

#1 deendee

deendee
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 22 May 2006 - 12:57 PM

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

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 22 May 2006 - 03:53 PM

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.

#3 morongo

morongo
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 17 June 2006 - 07:04 AM

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.







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users