QuickPHP Mod Documentation

QuickPHP - PHP Tester and Debugger (Lightweight PHP Web Server).

Suggestions? Comments? Bugs? Post your feedback here.

Moderator: Laffin

QuickPHP Mod Documentation

Postby ZachSaw on October 1st, 2008, 6:38 pm

Starting Version 1.4, QuickPHP supports using PHP scripts to implement extensions / mods (à la Apache modules such as mod_rewrite, mod_headers etc.).

QuickPHP calls QuickPHP_ReqMod.php (in the same folder as QuickPHP.exe) and passes the following variables to the script each time it processes a request. This enables the mods to modify the variables to implement functions such as mod_rewrite.

If QuickPHP_ReqMod.php file does not exist, QuickPHP simply works as before. This mod feature is for advanced users only.


Variables available to the script:

$DebugLog - Boolean - R/W - Default = false
Set this to true for QuickPHP to save the output from executing QuickPHP_ReqMod.php to QuickPHP_ReqMod_DebugLog.html (same folder as QuickPHP.exe).
This allows you to output message to the log file via Echo, Print, etc.

$RequestURI - String - R/W
Read from this variable to find out the URI being requested by the client.
Set this to any URI you wish to redirect the request to (e.g. for implementing mod_rewrite).

$RequestHeaders - String - R/W
Contains the request headers sent from the client.
The request headers are delimited by '\r\n' (return and line feed characters).
To add an arbitary header, simply append a new line to this variable and terminate it with '\r\n'.
There is no limit to the number of headers you can add.
Hint: Parse this string into an array to conveniently add or remove headers and then reconstruct the string at the end.

$UniqueID - String - R/W
Contains a unique ID for the current request.
If you wish to generate your own UniqueID in place of the default, change this value.

$ModuleSignature - String - R/W
Each module should append to this string to indicate its effects on the server.
e.g. ' mod_bwlimited/1.4' (Note the space before the name of the module).
Naming convention - ' <module name>/<version>'

$DocumentRoot - String - R
Holds the current DocumentRoot folder of this server.

$DefaultDoc - String - R
Holds the filename of the default document of this server.

The following are variables similar to $_SERVER['x'].
Some of these values will be updated to reflect the altered $RequestURI (if it is altered) after the execution of the script.

$GatewayInterface - String - R
$QueryString - String - R
$RedirectStatus - String - R
$RemoteAddr - String - R
$RemotePort - String - R
$RequestMethod - String - R
$ScriptFilename - String - R
$ScriptName - String - R
$ServerAddr - String - R
$ServerName - String - R
$ServerPort - String - R
$ServerProtocol - String - R
$ServerSignature - String - R
$ServerSoftware - String - R
$PhpSelf - String - R


*** R - Read-only. They can be changed in the script but will not affect the way server processes the request.
*** R/W - Read-write. Can be changed and will affect the server.


Notes:
It is recommended that you only include external PHP files from QuickPHP_ReqMod.php.
For example, for mod_rewrite, you could create a file called mod_rewrite.php, and include that in QuickPHP_ReqMod.php.

The QuickPHP_ReqMod.php file could end up calling several mods. In which case, it becomes a convenient place to enable / disable specific mods.

Example:
Code: Select all
include("mod_rewrite.php");
include("mod_log_referer.php");
include("mod_spelling.php");
// Disabled mods. Uncomment to enable.
//include("mod_unique_id.php");



Get started with this - it simply prints out all the available variables into QuickPHP_ReqMod_DebugLog.html:
Code: Select all
<?php
$DebugLog = true;
Echo $RequestURI.'<br>';
Echo $DocumentRoot.'<br>';
Echo $DefaultDoc.'<br>';
Echo $GatewayInterface.'<br>';
Echo $RequestHeaders.'<br>';
Echo $QueryString.'<br>';
Echo $RedirectStatus.'<br>';
Echo $RemoteAddr.'<br>';
Echo $RemotePort.'<br>';
Echo $RequestMethod.'<br>';
Echo $ScriptFilename.'<br>';
Echo $ScriptName.'<br>';
Echo $ServerAddr.'<br>';
Echo $ServerName.'<br>';
Echo $ServerPort.'<br>';
Echo $ServerProtocol.'<br>';
Echo $ServerSignature.'<br>';
Echo $ServerSoftware.'<br>';
Echo $UniqueID.'<br>';
Echo $PhpSelf.'<br>';
Echo $ModuleSignature.'<br>';
$ModuleSignature .= ' mod_bwlimited/1.4';
?>
ZachSaw
Site Admin
 
Posts: 103
Joined: July 4th, 2008, 2:56 pm

Re: QuickPHP Mod Documentation

Postby distortednet on October 3rd, 2008, 10:02 am

exaclty what i needed to test some stuff for an upcomming project.

is there a donate link anywhere? i havent had time to check. id like to donate a couple bux so you can buy beer, energy drinks, and snacks so you can keep coding into the night! DEVELOP DEVELOP DEVELOP!
distortednet
 
Posts: 15
Joined: August 2nd, 2008, 4:17 am

Re: QuickPHP Mod Documentation

Postby ZachSaw on October 3rd, 2008, 11:25 am

LOL. :lol: I'm doing this more as a hobby than anything else.

But if you want to contribute, I'd rather it be in the form of scripts to extend QuickPHP server, or to find out if Xdebug could be used with QuickPHP (if not, what needs to be changed).

Otherwise, you could always purchase a single user license of QuickPHP for Commercial Use at $29.
ZachSaw
Site Admin
 
Posts: 103
Joined: July 4th, 2008, 2:56 pm

Re: QuickPHP Mod Documentation

Postby Laffin on December 22nd, 2008, 4:49 pm

Xdebug does work for me, but I've been twiddling with xdebug configuration not shure which one caused it to work.
What I software I do got
QuickPHP 1.40 (WooHoo, nice its great for projects without apache hoggin everything)
PHP 5.2.8 (I want to develop some web apps with sqlite, so had to get it)
Xdebug v2.0.3 & debugclient-0.9.0.exe (the client is a good visual tool that xdebug is working)
and Dev-PHP2 editor (On source forge).

I just wanted something small and fast development environment. but like i said it took awhile to get xdebug working.

but here is my php.ini section for xdebug
Code: Select all
[Xdebug]
zend_extension_ts=C:\quickphp\ext\php_xdebug-5.2.5-2.0.3.dll
xdebug.default_enable=On
xdebug.debug_log_file=C:\quickphp\logs\devphp2.log
xdebug.remote_enable=On
xdebug.remote_mode=req
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey=devphp
xdebug.profiler_enable=On
xdebug.profiler_output_dir=C:\quickphp\profiler\
xdebug.profiler_output_name=timestamp
xdebug.remote_autostart=1


Note: the idekey is very importan. but I think it was the remote_autostart that did the trick (as it was one of the last edit I made), but it took a number of restart. s of QuickPHP to get it all working.... good luck.

Oh, I do have a request for a modification to QuickPHP. That is the ability to append to the QuickPHP Mod log file instead of overwriting it each and every time. This way it will be much simpler to create an apache type log, instead of using fputs or similar routine to make a log file.

Oh, and one more suggestion: FastCGI mod for PHP. this will definatelty help speed wise :)

Thanks again for a wonderful piece of software (No more looking up pages on httpd.conf or .htaccess) its much simpler using php as a general purpose module system.
Excellant work.
Laffin
Moderator
 
Posts: 18
Joined: December 22nd, 2008, 7:02 am

Re: QuickPHP Mod Documentation

Postby ZachSaw on December 22nd, 2008, 11:02 pm

Hey Laffin,

It's great to get an expert using QuickPHP - exactly what it needs to see some community contributions to push it forward. I'm still working on a better web server backend which is highly scalable and multithreaded. Reason to this is that the current web server implementation doesn't do a few things - such as flushing output buffers.

Thanks for the Xdebug usage info - I'll have a play with it when I get some time :)

Again, awesome stuff! ;)
ZachSaw
Site Admin
 
Posts: 103
Joined: July 4th, 2008, 2:56 pm


Return to QuickPHP

Who is online

Users browsing this forum: No registered users and 1 guest

cron