HTA and PHP. A match made in heaven?

Originally published: 06/2004 by J Wynia

Or maybe in hell. Who knows. I'm starting to feel like Dr. Frankenstein in my PHP experimentation. So, in another quest to do something just because I can, consequences be damned, I've taken the failure of the ActivePHP(see earlier this week) experiments and turned it into something that actually works. Fundamentally, the model that PHP, the browser and the web server operate on is passing HTTP messages back and forth. Once you remove the web server and substitute an HTA (HTML Application) for the regular browser page, all that needs to be stubbed in is a replacement for HTTP.

So, I did just that. I whipped up a series of Javascript functions that put the contents of a given form into a text file, call a PHP script on the commandline to process that text file and
then the PHP script sends back a message using another temporary text file. In short, round-trip communication. The current prototype uses calls to "php-cli scriptname.php" as its method for processing forms, but you could easily use Priadoblender-blended scripts instead to do the processing.

What you end up with is a simple way to build "stand-alone"
PHP applications without a web server and using HTML as your widget toolkit and GUI. In addition, the API for processing data is just like it is in a web app: simple name->value pairs. So, someone who is already familiar with building PHP web apps could quickly be up and running using this toolkit. Given the flexibility of this solution, it could become a viable alternative to PHP-GTK (at least for little scripts)

The thing still needs a name and some polish so name suggestions are welcome. I'll be putting it under an open source license on PHPGeek.com when it's done. Contact me if you want to play with a demo.

Comments

Mike on 12/1/2005
Hello, I'm very interested in having the ability to compile a php script into a stand alone windows application. As your article says, to contact you for a demo of your neato application. If you could send me a download URL that would be muchly appreciated. Thank You!
George on 1/30/2006
Hello there, I would like to see the demo. am waiting for full version with impatience. many thanks if you send me a link too.
Jimmy on 3/6/2006
Hi there, I was working on a similar project during the weekend, and every time I called the PHP script it opened the script in an editor. I will realy appreciate it if you could send me a URL to download the your demo. Many thanks!!
mon-loi perez on 3/31/2006
hmm..sounds really nice...can i have a copy of the demo.. -thanx..
J Wynia on 4/3/2006
Unfortunately, I lost this code in a hard drive crash.
Raf on 9/22/2006
Hey, I recently found about HTA files, that's excelent for simply GUI. If anyon's interested in reading php script output from hta application see my php-hta example: http://www.mahtar.net/files/hta-php-test.zip
Luke on 1/12/2007
Nice procedure. Got it to work for a previously web-based application. One query though - any quick way to support php sessions? I'm trying to whip something together but just wanted to know if someone had already done it.
J Wynia on 1/12/2007
I don't know of any reasonable way to automatically handle sessions. The Apache module version of PHP does a lot of work to just "magically" handle the sessions and that stuff isn't present in the CLI environment.
Jarodium on 5/13/2007
Hello I have checked out the script where you guys have php working along side HTA's. But instead by creating a text file and make it read it through PHP would not be simpler to use the StdOut property of the Wscript.Exec ? I guess is trickier tough...
Francois on 6/29/2007
Hi there !! The link to the file "hta-php-test.zip" above is broken ... could you please repair it because i would like to have a look at it ??? thanks a lot and congratulations for your site !! bye
ranger on 9/17/2007
I just discovered HTA (html applications). Currently looking into various ways to try and keep the hta files as open as possible (ie use of javaScript, php, etc instead of vbScript and other non-crossPlatform technologies). I'm really surprised that HTA isn't better known. It makes a great intro to programming via html, javaScript, client-side db connections, etc.. I'm looking for some OpenSource technology that's similar for Linux/*BSD - including Windows (essentially non-secure Kiosks - like any regular application with some additional presentation hooks to make the final product appear as a client-app). fyi... here's a downloadable demo I found using PHP on the back to process [FORM] info for anyone else interested in html as normal apps. http://www.phpgeek.com/pragmacms/index.php?layout=main&cslot_1=15
Raf on 11/2/2008
Link from from my previos comment (over 2 years ago, heh) now works: http://www.mahtar.net/files/hta-php-test.zip It's really basic sample of HTA + PHP working together. As Jarodium mentioned year and a half ago (heh2) HTA uses Wscript output to get the data from PHP script. NOTE: To get it working you have to drop files: php-win.exe and php5ts.dll from standard PHP zip file into folder or modify path to php-win.exe in HTA file. PS. If you use php.exe instead of php-win.exe you will see command line window... PS2. HTA has even nice window centering code ;P PS3. Recently I needed simple GUI with folder browser for my command line PHP script, preferably one I could run on Mac/Linux in the future...In this scenario HTA fails.I used C# and MONO to create basic GUI that runs PHP script with parameters and read output. Easier and quicker than rewriting whole PHP script in C# ;)
Peter on 10/28/2008
Hey there mate. I've heard of HTA before but haven't had the time to further investigate it. I am currently building desktop apps using a rather weird way to get an apache server and mysql up to run them. This HTA thing might boost my apps' result to the next level. I'd love that demo link and help if I could! Thank you in advance. Regards.
blog comments powered by Disqus
Or, browse the archives.
© 2003- 2013 J Wynia. Very Few Rights Reserved. This article is licensed under the terms of the Creative Commons Attribution License. Quoted content or content included from others is not subject to that license and defaults to normal copyright.