Re: Modular: Fusebox & Classes/OOP
| From: | Michael Kimsal | Date: | Sun, 19 Nov 2000 00:50:47 +0000 |
| Subject: | Re: Modular: Fusebox & Classes/OOP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-26090@lists.php.net to get a copy of this message | ||
This is somewhat similar to the FreeEnergy idea proposed by Leon Atkinson
on the zend.com tutorial area someplace.
We employ a similar method, but it's just a bit different.
We have one main index.php, and include a file based on the URL
http://www.blah.org/index.php/app1
This tells us that 'app1' is the file to include (might be app1.php or
whatever).
We include that, and it's a class declaration - more specifically, it's an
extended class of a main class we define in the index.php.
We write all of these include classes to have at least a 'run' method.
If we assume the 'app1' will be called $AF_SERVICE then in our
index.php we can say:
include ($AF_SERVICE.".php");
$service = new $AF_SERVICE();
if ($HTTP_POST_VARS["event"]!="") {
$a = "\$service->handle".$event."Event();";
eval($a);
}
$service->run($db,&$AF_USER,&$AF_OBJECT,&$TEMPLATE);
$service->template($TEMPLATE);
the 'run' method accepts standard arguments in every case,
and we can put extra variables in arrays under $AF_OBJECT or
could even globalize them.
Passing POST-method 'event' variables will run whatever 'event' method
is POSTed. POST with an 'event' for 'submission' and the 'submission'
method will be called. Only 'down' part of this is that you either
need to GLOBAL passed in variables, or GLOBAL the $AF_OBJECT
in the method, or *always* pass a set group of parameters to every
method in your class. We've not decided on a standard for our internal
use yet.
Like the method you propose, this keeps one main file free to handle
core stuff, like templating, database handling, error handling, user
authentication, logging, etc. And your 'app1'-type functionality
is left to a separate file.
A benefit of this *type* of approach is that the core engine can be
locked away someplace where 'junior' programmers can't get at it.
They don't need to remember to include DB stuff, etc. on every page,
nor can they 'mess it up'. They only have access to their segments of
code that will be included.
Did that confuse the issue more?
--------------------
Michael Kimsal
PHP meta searching
http://www.phphelpdesk.com/search/
734-480-9961