In the latest two weeks I was thinking about make some tests with ALPHA Framework and LightTPD. The goal of ALPHA Framework is that the application developers should take care about their web applications and don’t need to care about the other layers ( database, web server, authentication). With this concept in mind, the last week I’ve made some test to check the ALPHA Framework compatibility aganist the LightTPD and I got a good feedback from the tests.
First of All I’ve configured the LightTPD’s rewrite rules to reproduce the same I’ve written for the .htaccess file used with Apache and mod_rewrite.
## Enabling the mod_rewrite module for lightTPD server.modules += ("mod_rewrite") url.rewrite-once = ( "^([\?]*)(\?(.*))?$" => "/index.php?__url=$1&__fn=" + server.document-root + "$1&$3" )
The above rules trasform any url in the way ALPHA Framework would it.
The other changes I did is in the core file where I have added some control due the differences between Apache and LightTPD.
The differences I’ve found (and the most interesting for me) are that, during the execution of the page after the rewrite rule is that Apache Web Server expose the following server variables:
- REDIRECT_STATUS: the error code. If the request passed throught ALPHA rewrite rules, it would return 200 (OK)
- REDIRECT_URL
- REDIRECT_QUERY_STRING
LightTPD, instead, expose those data:
- REDIRECT_STATUS
- REDIRECT_URI
So, I discovered that REDIRECT_URL and REDIRECT_QUERY_STRING are condensed into REDIRECT_URI.
This is not bad because using a simple regular expression, I’ve regenerate the two missing variables:
if(preg_match('#^([^\?])(\?(.*))?$#', $_SERVER['REDIRECT_URI'], $matches)){ // if the request would be something like: /page.php?param1=a¶m2=b // the $matches array will contain: // [0] /page.php?param1=a¶m2=b // [1] /page.php // [2] ?param1=a¶m2=b // [3] param1=a¶m2=b $_SERVER['REDIRECT_QUERY_STRING'] = $matches[3]; $_SERVER['REDIRECT_URL'] = $matches[1]; }
another change I’ve done is to the $fileNameOnServer variable.
// $fileNameOnServer = $_GET[self:QUERYSTRING_FILENAME_PARAMETER]; // becomes $fileNameOnServer = $_SERVER['SCRIPT_FILENAME'];
I have to make further checks the above code within Apache environment and different contexts (app installed in the documentRoot and app configured in the subfolder).
In the next days, after a fast debug session, I will release a new version of the core full compliant with both Apache and LightTPD in favour of application portability!
If you like what you’ve read in this article and you would like to be involved in the ALPHA Framework developement, send me an email I will reply you as soon as possible!