PHP Developer / Programmer (NYC)
Next Step Systems
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume

"WebBox" Architecture in PHP
Each webbox is composed of several files and is stored in a single directory with an index.php3 file. To call a boxaction, the desired webbox's index.php3 URL is called and also passed the name of the boxaction to call along with any arguments to it. A typical URL style call would look like:
<a href="/people/index.php3?boxaction=viewcustomer&custid=12345">View Customer</a>
A typical form-based call to the same boxaction can be written:
<form action="/people/index.php3" method=post>
<index type=hidden name="boxaction" value="viewcustomer">
Enter the customer's ID number:  <input type=text name="custid">
<input type=submit value="View Customer Record">
</form>
A given webbox's boxactions are implemented in a single class called a "gateway". The index.php3 script instantiates the "gateway" class for its box. A long switch statement on the $boxaction parameter chooses the boxaction to call. Continuing our "add a customer" example, the relevant snippet of code from the index.php3 file might look like this:

<?php

$homedir
= "/www/htdocs/people/";

include
$homedir . "gateway.php3";
$g = new Gateway_People($homedir);

switch (
$boxaction) {

    case
"viewcustomer":
        
$g->viewCustomer($custid);
        break;

    case
"checkauthentication":
        
$g->checkAuthentication($username, $password);
        break;

    
//
    // Other boxactions
    //

    
default:
        
$g->showDefaultPage();
        break;
}

?>
As is clear from this example, the gateway class is stored in a file named gateway.php3, and the class is named "Gateway_<name>", where <name> is the "name" you've given to the box (in our example the name is "People"). The gateway class is stored in a .php3 file to avoid exposing secrets like passwords or other sensitive information you don't want the public to see. It should only contain the class definition, no active script or HTML. Having the gateway class is necessary for calls to a webbox from script outside its directory [For you fusebox aficionados out there, the gateway is necessary because there is no <CFMODULE> tag in PHP which allows you to pass arbitrary arguments.]
Next Page

[Page 1]  [Page 2]  


Comments:
RE: PHP/fusebox exampleBoyNextDoor06/17/03 12:48
RE: FB3 and Templates?BoyNextDoor06/17/03 12:36
FB3 and Templates?Jonathan Griffin12/30/02 02:44
RE: Fusebox has no place with PHPCoolfires12/27/02 06:36
RE: Refresh ..! Help ...!!!Jason05/08/02 20:11
Tutorial HereRod05/07/02 12:10
Fusebox is a good ideaJosep05/07/02 11:07
PHP/fusebox examplekace05/04/02 08:49
RE: PHP is short for? Bill Gates02/27/02 08:01
PHP in multi tier architectureSrinivas12/05/01 02:29
Defaults?Bryan11/28/01 17:05
RE: Fusebox has no place with PHPAntonio Mokarzel11/26/01 11:36
RE: Why not OO?Dan Tansanu10/24/01 00:14
Any FULL examplesEddie10/19/01 12:02
RE: Why not OO?piero09/22/01 03:24
Why not OO?Karim09/18/01 12:19
RE: Fusebox has no place with PHPRicardo09/10/01 11:35
RE: Fusebox has no place with PHPFrank Uplands07/23/01 20:11
Refresh ..! Help ...!!!Ashraf Baroudi07/03/01 23:18
RE: PHP is short for? VNCoder06/28/01 18:30
RE: PHP is short for? Mark S.06/28/01 15:58
RE: PHP is short for? Larry Ullman06/19/01 12:36
RE: PHP is short for? Jon Adams06/18/01 11:39
RE: PHP is short for? Oktay Altunergil06/07/01 16:58
Other modelEldes de Paula05/14/01 12:36
RE: PHP is short for? freakysid05/13/01 21:13
RE: Fusebox has no place with PHPTim Lieberman05/13/01 11:29
Fusebox has no place with PHPTobyWong05/11/01 10:22
RE: PHP is short for? Richard05/07/01 22:46
PHP is short for? Aisha04/26/01 03:43
RE: Do we need more words?John Farrar04/17/01 15:48
RE: Whats so special about Fusebox?John Farrar04/17/01 15:44
RE: Do we need more words?David Martinez04/09/01 13:16
RE: PHP-FuseBox newsgroup (egroup)rITESH03/11/01 06:55
RE: fusebox?Steven02/09/01 10:55
RE: Whats so special about Fusebox?Gordon Goldner02/06/01 12:25
PHP-FuseBox newsgroup (egroup)Rene Nederhand01/31/01 08:16
mSQL-PHP3 (miniSQL)Christian Vizcarra Guerrero01/27/01 01:33
Do we need more words?Scott01/10/01 09:19
RE: optimized version of function based fuseboxBen01/05/01 12:35
Whats so special about Fusebox?Ben01/05/01 12:33
RE: Some thoughtsBaruch Even01/04/01 05:23
optimized version of function based fuseboxPaul Meagher12/15/00 11:44
Example of function based fuseboxPaul Meagher12/15/00 11:00
RE: fusebox?Steve Beuret11/29/00 08:32
Why a gateway classSteve Beuret11/28/00 09:56
fusebox?Terence11/27/00 23:40
RE: includes vs. functionsFaSer11/10/00 06:48
includes vs. functionsSteve Nelson11/09/00 14:12
RE: Advantages over function includesSteve Nelson11/09/00 13:58
Advantages over function includesJacob Hanson11/08/00 13:58
Sessions In PHP/FuseboxBill Holloway08/19/00 12:19
RE: Some thoughtsBill Holloway08/19/00 12:02
Some thoughtsIlja Heitlager08/14/00 18:32
 

If you are looking for help, please post on the appropriate forum here. Your questions will be answered much more quickly.

Add A Comment:

Name:

Email:

Subject:

Message:

To reduce spam posts, messages are now manually approved

You are not [logged in]. That means your account will not get credit for this post.