Model View Controller (MVC) frameworks in PHP
| From: | Terence Kearns | Date: | Thu, 04 Jul 2002 05:17:54 +0000 |
| Subject: | Model View Controller (MVC) frameworks in PHP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-105365@lists.php.net to get a copy of this message | ||
I've been developing an open source MVC framework in PHP and it's going OK. However, I
wanted to find out about any other frameworks around the place that do a similar thing. I want to
see how other people approach this design pattern.
Here are my main aims:
1) standardise development patterns so it is easier to understand other people's code
2) standardise repository/library building so that applications scale features (modules) in an
organised manner.
3) provide a central point of configuration to make porting and deploying applications to different
environments less painful.
4) provide a standardised way of abstracting interface design from content generation.
5) provide a consistent approach to exception handling
6) provide a consistent approach to content delivery and make it easier to solve cross-platform user
agent issues.
7) KISS (keep it simple stupid)
and corresponding Objectives:
1a) enforce a 100% OO approach to application design using inheritence (implemented object
factories). The modularisation of an application should be restricted to class definitions. So the
only include() statements should be at the top of a class definition which includes other classes.
1b) promote the usage of PHPdoc and documentation in general
2) Establish a convention for the naming and storage of packages and class definitions so that
someone can unzip a package into the tree and use it out-of-the-box (through the URL)
3) use one script as a single point of access which can control configuration settings. Instead of
every script needing o include a particular configuration file, one file (with the configuration)
will invoke and pass-through every script (class definition).
4) the MVC should assume output is in XML (content centric) and provide standard mechanisms for
passing it on to display processors (such as XSLT processors). shuch mechanisms will include
conventions for declaring and locating templates (XSL files).
5) utilise the custom error handling capabilities of PHP to raise and handle exceptions in an
organised way.
6) <see point 4>. Also, the controller should help the developer make decisions on how to
process the output based on user agents or other conditions.
7) the only thing a backend developer need worry about is returning XML output from her/his
"external" method. The only thing a GUI developer need worry about is where to put their
XSL templates.
At the moment, I'm not considdering performance (shock, horror). Of utmost importance is make
the life of a developer much easier in both short and long-term (when the codebase gets really big).
Once the model has stabilised, I can tweak it without compromising the useablity for developers. The
model may include provisions for a distributed implementation. It already has provisions for content
caching (XML) and may be extended to include output caching (post XSLT). As it happens, the
controller is actually written procedurally for reasons I won't go into at this point (this may
change).
Other offerings:
I have checked out fusebox (FB) (which was initially designed for ColdFusion (CF) but is also
available in PHP). It was interesting to see that FB was very similar, in the way methods (or
"fuse actions") are called, to how I do it. However, I'm not a big fan of FB for PHP
since I like to use an OO methodology. FB is good for CF though.
http://www.fusebox.org/
And I am about to check out Krysalis which looks to be quite comprehensive.
http://www.interakt.ro/products/Krysalis/index.php
Depending on my progress, I will be posting something on my website under the "projects"
heading.
here's a nice gentle introduction to MVC
http://www.newarchitectmag.com/documents/s=2412/new1020217692284/index.html
Once again, if anyone can point me to other existing examples, please point :)
Credit where credit is due: I should mention that one of the things that inspired me in the first
place was
http://dcl.sourceforge.net/docs/developers/dcl_developer.html
This is a very cool tool. I type of CRM I guess.