#native_company# #native_desc#
#native_cta#

WebBox (Fusebox) Architecture Page 3

By Bill Holloway
on July 30, 2000

The boxactions implement their functionality by calling other
objects, INCLUDing .php3 file, etc. The gateway class instantiation passes
the box’s directory to the constructor because INCLUDE statements in the
gatway class need the full path to the .php3 file. This is
necessary for boxaction calls that originate in directories outside the box’s
directory.
Some gateway functions are fully private to the gateway class, being called
only internally. These should be prefixed with an underscore or some other
identifying prefix or suffix to denote that they are “private” functions.
Boxactions or private functions which produce no output should be prefixed with
some abbreviation of the action the function does, like “qry_”.
Obviously, the gateway class is the repository for all the implementation of
the boxactions. Thus the gateway class can have MANY lines. To
reduce the size of the gateway class file, remember to delegate tasks to other
classes, static HTML files, and .php3 files.

CALLING BOXACTIONS FROM PHP SCRIPT

To call a boxaction from PHP script, simply instatiate the appropriate gateway
class and call the function on it. Here’s an example calling our “View
Customer” boxaction from PHP script:

<?php

include $web_root_directory "people/gateway.php3";

$people_g = new Gateway_People($web_root_directory "people/");

$people_g->viewCustomer($custid);

?>



The real beauty of this is the reusability of the code. Because we are wrapping
basic functions in classes, they can be included for use throughout a site.
It’s also a win for any future programmers that have to look at the code. A quick glance
at the index file will show you the case statement and the corresponding classes. That’s
quite a bit cleaner than searching through dozens of separate php files and includes to
get an idea of what’s happening.
I hope this helps you get started. For more information, you can visit
www.fusebox.org..
–Bill