PAW supports BeanShell code to create dynamic pages. BeanShell is well suited for Android, because it integrates will into the OS by supporting the Android Java API.
The foundation of PAW is Brazil a web application framework which was developed by SUN (now Oracle). Although not widely used the framework has the advantage of being very small and flexible.
What I was thinking about for a while was to add PHP support. PHP is widely used around the net. PHP's reputation is questionable and that are people who love and others who hate it. But it's undoubtedly one of the most used frameworks when it comes to web development.
PHP basically comes in two flawors, a CLI and a CGI version. To integrate PHP into the context of a web server the CGI version is needed.
Android PHP Project
Knowing that there is a CLI version provided by the Android PHP Project I headed over to their forum asking if they could provide a CGI version in addition to the CLI version.
Unfortunately the guys told me that a CGI version will not be provided by the project because it's not needed and pointed me to a page which describes shortly how to setup the tool-chain to do a cross compile of PHP.
So I tried to compile PHP myself. I have a Linux box at home so I'm quite familiar with doing configure/make and all this things but the last time I dug into C sources and header files is approx. 10 years back. So this was quite a challenge. Finally I got it working, but I think I did a lousy job. So if somebody can do it better, please go ahead and send me the php-cgi binary.
The CGI Handler
After I had the binary I extended and changed the CGI handler that is included with Brazil to work with Android. Due to some changes in the Brazil source that I have done concerning upload size limits the original handler could not be used. In the process I also tried to add SL4A support. I haven't tested this until know, but I hope it will be working.
SL4A support is a little bit tricky, because one has to know the port the SL4A is listening to. So I looked around how to get hold of the port and found out that the port is reported in the logcat.
So on startup of the handler (on start of the PAW service) the handler looks into logcat and tries to find the SL4A host name and port number. These values are associated with the AP_HOST and AP_PORT environment variables. So SL4A the server has to be started shortly before PAW starts up.
PHP will be available as plugin shortly after the next release of PAW (which should be in the next month). PAW will then come with the new handler. Providing PHP as plugin has the advantage that PAW itself does not grow (much) in size. PHP is approx. 3 MB in size and so relatively large.
The plugin can be downloaded from an external website and extracted into the PAW plugin folder.
A new page showing available plugins will be included into the next PAW release.
|Plugins in the Add-Ons menu|
After extracting the plugin it should be visible under PAW's plugin menu.
|Plugin in the Plug-ins menu|
Installation of PHP should be a one click action and after a restart of PAW PHP should be available.
PHP has been tested using a Google Nexus One and a Notion Ink Adam. The result of phpinfo() can be viewed here.
This is work in progress but it looks promising although not all PHP pages will be working but basic stuff should.
So stay tuned, I hope to finish this in a couple of weeks :)
PAW for Android 0.58 is now available at the Android Market.
The PHP plug-in is also available.
If you have trouble downloading the PHP plugin from the original location, you can try the alternate link at Google Drive: PAW Plugins