|
"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
Next Pagegateway.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.]
| Comments: | ||
| RE: PHP/fusebox example | BoyNextDoor | 06/17/03 12:48 |
| RE: FB3 and Templates? | BoyNextDoor | 06/17/03 12:36 |
| FB3 and Templates? | Jonathan Griffin | 12/30/02 02:44 |
| RE: Fusebox has no place with PHP | Coolfires | 12/27/02 06:36 |
| RE: Refresh ..! Help ...!!! | Jason | 05/08/02 20:11 |
| Tutorial Here | Rod | 05/07/02 12:10 |
| Fusebox is a good idea | Josep | 05/07/02 11:07 |
| PHP/fusebox example | kace | 05/04/02 08:49 |
| RE: PHP is short for? | Bill Gates | 02/27/02 08:01 |
| PHP in multi tier architecture | Srinivas | 12/05/01 02:29 |
| Defaults? | Bryan | 11/28/01 17:05 |
| RE: Fusebox has no place with PHP | Antonio Mokarzel | 11/26/01 11:36 |
| RE: Why not OO? | Dan Tansanu | 10/24/01 00:14 |
| Any FULL examples | Eddie | 10/19/01 12:02 |
| RE: Why not OO? | piero | 09/22/01 03:24 |
| Why not OO? | Karim | 09/18/01 12:19 |
| RE: Fusebox has no place with PHP | Ricardo | 09/10/01 11:35 |
| RE: Fusebox has no place with PHP | Frank Uplands | 07/23/01 20:11 |
| Refresh ..! Help ...!!! | Ashraf Baroudi | 07/03/01 23:18 |
| RE: PHP is short for? | VNCoder | 06/28/01 18:30 |
| RE: PHP is short for? | Mark S. | 06/28/01 15:58 |
| RE: PHP is short for? | Larry Ullman | 06/19/01 12:36 |
| RE: PHP is short for? | Jon Adams | 06/18/01 11:39 |
| RE: PHP is short for? | Oktay Altunergil | 06/07/01 16:58 |
| Other model | Eldes de Paula | 05/14/01 12:36 |
| RE: PHP is short for? | freakysid | 05/13/01 21:13 |
| RE: Fusebox has no place with PHP | Tim Lieberman | 05/13/01 11:29 |
| Fusebox has no place with PHP | TobyWong | 05/11/01 10:22 |
| RE: PHP is short for? | Richard | 05/07/01 22:46 |
| PHP is short for? | Aisha | 04/26/01 03:43 |
| RE: Do we need more words? | John Farrar | 04/17/01 15:48 |
| RE: Whats so special about Fusebox? | John Farrar | 04/17/01 15:44 |
| RE: Do we need more words? | David Martinez | 04/09/01 13:16 |
| RE: PHP-FuseBox newsgroup (egroup) | rITESH | 03/11/01 06:55 |
| RE: fusebox? | Steven | 02/09/01 10:55 |
| RE: Whats so special about Fusebox? | Gordon Goldner | 02/06/01 12:25 |
| PHP-FuseBox newsgroup (egroup) | Rene Nederhand | 01/31/01 08:16 |
| mSQL-PHP3 (miniSQL) | Christian Vizcarra Guerrero | 01/27/01 01:33 |
| Do we need more words? | Scott | 01/10/01 09:19 |
| RE: optimized version of function based fusebox | Ben | 01/05/01 12:35 |
| Whats so special about Fusebox? | Ben | 01/05/01 12:33 |
| RE: Some thoughts | Baruch Even | 01/04/01 05:23 |
| optimized version of function based fusebox | Paul Meagher | 12/15/00 11:44 |
| Example of function based fusebox | Paul Meagher | 12/15/00 11:00 |
| RE: fusebox? | Steve Beuret | 11/29/00 08:32 |
| Why a gateway class | Steve Beuret | 11/28/00 09:56 |
| fusebox? | Terence | 11/27/00 23:40 |
| RE: includes vs. functions | FaSer | 11/10/00 06:48 |
| includes vs. functions | Steve Nelson | 11/09/00 14:12 |
| RE: Advantages over function includes | Steve Nelson | 11/09/00 13:58 |
| Advantages over function includes | Jacob Hanson | 11/08/00 13:58 |
| Sessions In PHP/Fusebox | Bill Holloway | 08/19/00 12:19 |
| RE: Some thoughts | Bill Holloway | 08/19/00 12:02 |
| Some thoughts | Ilja Heitlager | 08/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. | ||


