views:

651

answers:

2

Hi, I want to build an app that does the following:

1) Take a user-supplied PHP script and pass it to the PHP interpreter to execute it.

2) Take the output, whether it be from memory or a temp file, and pass it to a Web Browser hosted in the app, to show the HTML

3) Handle the http requests I.E. the user's clicks, so instead of making the http request through a web server, another local PHP script gets called and again to step 1)

This is to have a way to use PHP for desktop scripting while having the benefits of a web GUI, and not having to use a web server. If you would like to discuss if this is a good idea or not, or if you would like other language better, etc. you're welcome, but What I'm most interested in getting here is:

a) What way do you recommend to host a web server in the app? CWebBrowser, CHTMLView, other?( I think of IE, although I use firefox, I think IE would be the easiest to implement, at least at the beggining. I don't have much experience on the win32 API )

b) Do you know any good tutorials or articles that explain how to do a) with good detail?

Requirements: C/C++ & Windows. ( No .NET ) Why? because that's what I know and feel more comfortable with.

If this proves to be useful I'd like, in the future, to port it to other platforms like Linux and to use better browsers, like Mozilla.

Thanks!

+5  A: 

You could always use QT, which, as of version 4.5 is LGPL and (since 4.2, I think) includes a port of WebKit, the rendering engine used in Safari and Chrome, among others. It would also greatly simplify porting to other platforms, since QT (and WebKit) are highly cross-platform.

The documentation is very good.

I believe you can also embed PHP, which would make delivering the script output rather trivial.

greyfade
Embedding PHP sounds good, will be on the future wish list.About QT, why not just using Webkit directly?
Petruza
QT's version of WebKit is already ported. All of the work of making WebKit work has already been done for you. It's also fairly well integrated into QT itself.If you use WebKit by itself, then you end up using a native version on Windows... And then you'll have to port your application to use WebKit on the Mac, and WebKit-GTK or QT-WebKit on Linux... May as well just cut out the wasted work before you do it and just use a cross-platform toolkit from the outset.
greyfade
Hey thanks for the guidance, I've had a look at the QT site and downloaded C++ Programming with QT 4* looks a good choice!*(it's free in case somebody wonders)
Petruza
And the single source portability of QT is a big plus!
Petruza
A: 

You may want to instead look at writing desktop applications in PHP. This article talks about doing that with PHP-GTK. I haven't used this, but it looks like a pretty nice way of doing what you are talking about.

http://www.developertutorials.com/tutorials/php/building-desktop-applications-in-php-8-02-01/page4.html

This is the main site for PHP-GTK: http://gtk.php.net/

For a discussion as to the pros or cons of what you are trying to do you can look at: http://stackoverflow.com/questions/40870/why-dont-people-use-php-for-desktop-applications

James Black
Yes, I've been there too, made some things with Mini PHP Studio.It's good. But what I want to do is have a launcher app, and then throw some PHPs to it and have it execute them, and not having to re build the app everytime. Thanks anyway!
Petruza
Then it may be best to have a webserver running on localhost, so you don't have to care if they use apache, IIS or whatever, as long as it has PHP, and just have a config file that tells them where to go, and then just embed IE in your application.
James Black