Running PHP in custom www server app

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
We are developing a (Win32) C++ application which among other things is
able to generate some HTML pages and send them to an HTML client (in the
same app actually). Now for more flexibility we would like to filter the
generated pages through PHP. What should be the best/easiest way to
proceed? I would like to avoid any temporary files as much as possible.

1. Use _popen or CreateProcess to launch PHP-CGI.EXE, feed the input file
in stdin and capture stdout. I'm afraid this will create nasty black  
windows on the screen.

2. Include <php.h> etc and call php_execute_script() et al directly (are
these documented somewhere?). Seems to be very file/stream-oriented, I
would like string-in, string-out instead.

3. Install php ActiveScript support and call it via COM interface. Seems
to be the cleanest approach, but how to do it in C++? Any examples?

4. ...?

Also, what possibilities are there to pass data to php? Again, I would
like to avoid temporary files. Possibly to inject variable/array creation
PHP code directly in the passed script text?

thanks in advance

Re: Running PHP in custom www server app

Quoted text here. Click to load it

Please clarify what you are referring to as "filtering" pages through
PHP.  It sounds like you want to generate PHP code to be executed, but
I am not sure...

Also, you forgot to mention what HTTP server you are using...  PHP can
be deployed on a variety of servers, quite often in more than one way
(CGI binary vs. module on Apache, CGI executable vs. ISAPI module on

Quoted text here. Click to load it

Assuming you want to generate (and then run) PHP code, the easiest way
would be to pass a chunk of PHP code via POST to this simple snippet:


Obviously, you may want to implement some security checks (i.e., send
additional data to be used for authentication).  


Re: Running PHP in custom www server app (Nikolai Chuvakhin) wrote in message
Quoted text here. Click to load it

Sorry if I was unclear. There is no HTTP server, nor can we make use
of one as the app will be distributed to end users who don't have it

Instead, our app itself acts as a HTTP server. It listens on some port
and provides HTML pages for the CHtmlView controls sitting in the same
app. It's quite easy as there is (almost) no question of security,
transaction speed, support of n+1 protocols, etc. However, now has
arisen a need to add PHP support to our "server"...


Re: Running PHP in custom www server app (Paavo Helde) wrote in message
Quoted text here. Click to load it

Oh, I see.  In this case, you need to use the command-line interpreter,
which does not require an HTTP server.  You can pipe output of your
application to the command-line interpreter's STDIN and receive the
output via STDOUT.

For more information, read The Manual:


Site Timeline