Forum Moderators: coopster

Message Too Old, No Replies

I just found a project called MozPHP...

Run PHP scripts locally -- without a web-server!

         

MonkeeSage

2:22 am on Oct 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am playing with making a Mozilla App using XHTML and PHP instead of XUL and JavaScript...the problem of course is that PHP is a server-side language and can't very easily replace JS for client side tasking. But I don't really feel like 1000+ lines of PHP into Javascript! So what I was trying to do was call the script through the php binary and capture the output to the browser, which it would then render as HTML. But I couldn't get the stupid nsIProcess interface to instance correctly for some reason.

Anyhow, I was either going to just bite the bullet and code the JS or try to write a small PHP wrapper as a plugin.

Well, I happened to be browsing MozDev earlier and I came across a project called MozPHP -- a set of libraries (two, to be exact) which doesn't just wrap the PHP binary but actually calls it through the SAPI just like a real server would!

I downloaded the Mozilla 1.4 binary package for windows provided by the author (there is also a Linux binary package) and grabbed a copy of Mozilla 1.4, followed the install instructions, and viola! Works great! Extreemly fast too! :D

Also, since it is opensource, it could also be compiled for, e.g., Firebird, or Mozilla 1.5 and (in theory) it would work just as well.

Too cool!

Jordan

jatar_k

6:21 am on Oct 13, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



that is pretty cool I'll have to take some time and check that out

ergophobe

4:41 pm on Oct 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Okay, so maybe I'm dense (must be since everyone seems immediately excited), but I don't really see how I would use it.

Monkee, are you thinking of an app that you would distribute as a package (say Mozilla, MozPHP, your app itself all in a zip file), compiled for various platforms? Then the end user would have to install it, but would not need to have a PHP server installed on her machine?

Is that all there is to it? In other words, does the user need to run some installer (other than installing Mozilla obviously), or does she need to install Mozilla, MozPHP, and then your app?

MonkeeSage

9:43 pm on Oct 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



ergophobe:

You have the right idea. You just unzip MozPHP package to the Mozilla directory, set up a mime type for text/php and then you can use a special pseudo-protocol (cfh://) to execute any local PHP script in Mozilla without needing a local PHP server.

MozPHP consists of two components:

PHPToHTMLConv
A stream converter for the conversion of PHP files to HTML. The stream converter integrates a PHP SAPI module.

CFH_Protocol
A protocol handler that partly implements the file protocol and the http protocol.

The only limitation the author is aware of is:

You cannot (yet) set cookies using PHPs
setcookie
function.

As for my app...thing, I was just giving a bit of background as to why I was looking for a PHP wrapper. I'm not sure how I will handle deployment yet, but I'm thinking it will probably be a custom build of Firebird / MozPHP with my app as a standard chrome package. A person will just download the package and then unzip it to some directory and then run a .bat file or .sh script that calls 'MozillaFirbird -chrome' with my app's chrome path.

Jordan

ergophobe

9:58 pm on Oct 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hmm.... That sounds pretty useful in theory. No projects yet that I could use with it, but who knows.

Thanks

killroy

10:07 pm on Oct 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Now if you could hook it up with the inline version of MySQL you have a nice platform for CD apps that don't need to be installed.

SN

sun818

10:19 pm on Oct 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Sorry, a little off topic. killroy, there is a free product from IndigoPerl called MicroWeb [indigostar.com] that will do what you're suggesting. I could send my customers an interactive web site with search capbilities. Might have to tweak the code because of the read-only aspects of a CD, but it is pretty cool nonetheless.

ergophobe

5:18 pm on Oct 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I forget the details, but the forthcoming versions of PHP will have an integrated SQL database, so you won't need anything but PHP (and correct file perms and all that).

Tom

wruk999

5:48 pm on Oct 14, 2003 (gmt 0)

10+ Year Member



killroy,

I don't know whether this is the kind of thing your looking for, but this thread was extremely enlightening ;)

Putting a new dynamic PHP/MySQL site on a cd-rom [webmasterworld.com]

Cheers,
wruk999