Monday, January 25, 2010

AIR 2 Beta native process and the PHP CLI

With the release of the Adobe Air 2 beta comes a rake of cool new features. The most promising amongst them for future development is the ability to call and communicate with native processes on the machine on which Air is running. This obviously opens up all sorts of possibilities for extending the capacity of AIR without the need for the required API to be a part of AIR itself.

The application I'm building has so far has been slowly growing as a bunch of Flex applications, working with MYSQL via AMFPHP. But as more things are moved into AIR I wanted to get rid of the need for the webserver, in the case of the application working standalone on a local machine with a local installation of a MYSQL database.

Using the new native process API in AIR, and the CLI version of PHP, I've managed to come up with a way of communicating with AMFPHP directly through STDIN and STDOUT without the need for a webserver. The code is in its infancy, but I thought this would be a good time to share the idea and get some comments and input from those of you out there who are working in the same environment.

Rather than trying to post the code here on the blog - I've opened a Google Code project so that anybody who's interested can download the code and develop the idea if they want to. The project is at - you can download from subversion or there's a zip that you can download for convenience.

My main concern so far is security. For this to work on in a live application scenario on a user's machine the first consideration would be to have the PHP code compiled and have some way of securing the PHP installation against possible attacks. Any comments and/or suggestions on this or any other areas of concern regarding security on this particular idea would be appreciated. I suppose the other concern might be somebody hooking something in between the parent and child process...

There is a truly annoying caveat with AIR on Windows at the moment. If you install and run an AIR application using the 2 beta you get a command line pop-up window appearing each time you run php.exe (or it seems any other command line executable). I was hoping Adobe would come up with a fix for this before a production version is released, but looking at the Adobe Forums, Chris Thilgen is telling us that it won't be... (apparently its a "feature request" to not show the command window!)

Maybe next time eh?

No comments: