MVC Framework/Features of other Frameworks
Main editor: Nick Weisser
What do current MVC Frameworks achieve?
It is indendent to be a discussion base for potential features of the upcoming T3 lib/div api.
- Automatic model generation from either DB tables or XML description file. This requires strict naming conventions.
- Standard model methods for every model like findAll, findBy[fieldname], delete, save etc. For a full list see: http://manual.cakephp.org/chapter/models or http://www.symfony-project.com/book/trunk/model
- Every standard method provides a hook before and after execution e.g "before/afterSave".
- Model association and automatic fetching of related models.
- Model relations are defined within the model either via php array or xml. E.g :
var $belongsTo = array('User' => array('className' => 'User', 'conditions' => , 'order' => , 'foreignKey' => 'user_id' ) );
- Association is considered on fetching, writing and deletion.
- Association can be unbound on demand. (To avoid fetching of assioated records if they are not needed)
- Association can be also defined by a custom SQL query to keep things flexible.
- Validation rules can be defined within the model. They are evaluated on save/update and an error code is returned to the particular controller. A set of predefined validation rules is existing e.g isRequired, isEmail etc.
- Automatic controller model binding on naming conventions. (Can be extended by setting a variable in case a controller uses several models)
- Filters/hocks are provided by the controller prototype class (e.g. before/after).
- Functions needed by several controllers can be packaged as so called components and embeded into every controller. There is a set of usefull standart components e.g a request handler which allows to determine whether a request is an ajax request or not.
- ActionRequest enables a controller to call an action from another controller without perfoming an "header location redirect" and use the returned view within its own view.
- Opportunity to use the template parser of your choice (where phphtml is default)
- Powerfull set of helper classes for generating common html tags.
- Automatical handling of form validation errors (see model). If the validation for the field body of the model note fails an error message is displayed. E.g:
echo $html->tagErrorMsg('Note/body','Please enter in a body for this note.')
- HTML/Template subparts needed in several views/templates can be packaged as so called elements.
- Ajax helper class using prototype/scriptaculous.
- Master template can be defined via a so called layout. E.g:
<div id="header"> <div id="menu">...</div> </div> <!-- Here's where I want my views to be displayed --> <?php echo $content_for_layout ?> <!-- Add a footer to each displayed page --> <div id="footer">...</div>
- The default layout can be overwritten by the controller. This is especially usefull in conjunction with the requestHandler component and Ajax.