Embedding PHP into an application in C/C++

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
TiGr0u
Forum Newbie
Posts: 2
Joined: Fri Jul 18, 2003 5:07 pm

Embedding PHP into an application in C/C++

Post by TiGr0u »

Hi

I would like to integrate the PHP interpreter in order to be able to script my application with php script. Is it possible ? Where can I find doc ?

Thanks

--
Damien
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

first you should read the Zend engine license (It differs a lot from the PHP license), there are some very strict wordings in there, not sure if it involves usages but it certainly involves all sorts of changes and integration.. But if the license is usable you can certainly use the engine API directly, although many have complained there is a great lack of documentation and code-comments for this.. (Zend/PHP isnt as open and free as many believe)
TiGr0u
Forum Newbie
Posts: 2
Joined: Fri Jul 18, 2003 5:07 pm

Post by TiGr0u »

thanks a lot for your answer.

It seems to be the reason why I don't find any things on that topic.

--
Damien
burek
Forum Newbie
Posts: 6
Joined: Mon Oct 06, 2008 9:48 am

Re: Embedding PHP into an application in C/C++

Post by burek »

i would also like to use php as a scripting language for my application (written in c++), because of the popularity of php and its easyness to learn..
are there any links that can help me to do this with php (i dont want perl/python/lua.. i want php)

thanks in advance for any help on this..
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Embedding PHP into an application in C/C++

Post by josh »

Uhh you could have your APP just use the PHP CLI and implement a basic framework in PHP, letting framework implementers create a subclass with overridden template methods specific to your domain
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: Embedding PHP into an application in C/C++

Post by Kieran Huggins »

Do you mean bindings?

http://objectmix.com/ruby/346743-help-u ... dings.html

Somehow I doubt PHP is the ideal language for this... you should really reconsider a more flexible language like Ruby or LUA. PHP is mostly just a collection of compiled functions with a (very) good manual.
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Re: Embedding PHP into an application in C/C++

Post by Mordred »

+1 for Lua.
burek
Forum Newbie
Posts: 6
Joined: Mon Oct 06, 2008 9:48 am

Re: Embedding PHP into an application in C/C++

Post by burek »

I know how to do it with Lua, but I need to do it with PHP.. Is this possible?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Embedding PHP into an application in C/C++

Post by Chris Corbyn »

Bundle PHP with the app. You can compile PHP as a command line executable just like perl or python. Then you can just make exec or system calls to the binary.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Embedding PHP into an application in C/C++

Post by Weirdan »

There's only one good source of information on this subject I'm aware of (except reading the source code, of course :D ) - the book Extending and embedding PHP. Your will have to buy it though - Google's copy skips some pages.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Embedding PHP into an application in C/C++

Post by josh »

This book is golden, thanks. $2 used in amazon marketplace - I had to directly bypass my wishlist queue ;-)
burek
Forum Newbie
Posts: 6
Joined: Mon Oct 06, 2008 9:48 am

Re: Embedding PHP into an application in C/C++

Post by burek »

Thank you for your help, I've found a book on some dc hub (63KUZCCV4FJHCW3YIIHIEPK5MABL55Z76HWG5NQ) and it is really helpfull, so I'll take a look into it.

Once again, thanks a lot for the help.
SteelSlasher
Forum Newbie
Posts: 5
Joined: Fri Sep 12, 2008 12:54 pm

Re: Embedding PHP into an application in C/C++

Post by SteelSlasher »

Just adding a suggestion here-

You could use WinBinder which lets you use the win32 api within your php app so in theory you could use this. It can also be intergrated with c++ by using dlls

You could also use php-gtk but i havent used that before so i cant recommend it but only suggest it
jason.carter
Forum Commoner
Posts: 35
Joined: Sat Jan 10, 2009 10:05 am

Re: Embedding PHP into an application in C/C++

Post by jason.carter »

Also, a good idea to try the VxWorks and also the GoAhead web server. Embedded webserver and it supports PHP.
Post Reply