Framework

The framework revolves round the concept of MVC design pattern as expected. There are four elements: 1. web browser, 2. Controller, 3. Model, and 4. View. These four elements interact with one another to establish a data-flow that is initiated by HTTP Request from client browser, and is successfully terminated with the receipt of HTTP Response at the client browser. Please see the illustration of data-flow within the framework below.

Data-flow within ash.MVC framework

Figure: Illustration of Data-flow within ash.MVC Framework

After initiation of data-flow at the client browser, HTTP Request is received at the web server. The Request contains the location and various parameters available through $_REQUEST (or, $_GET and $_POST) super-global variable. These input parameters are execution parameters as they are responsible for defining a path of execution during the run-time.

Controller is invoked with HTTP request, and then defines the execution path with the help of execution parameters. With all input data assembled and the control flow defined, Controller calls Model for implementing the business logic (BL). Model carries out BL processing, and returns resulting data in the form of arrays. After successful interaction with Model, Controller passes the available resulting data to View for composing the GUI. View creates the final client-side code (all in XHTML, JavaScript, CSS, etc.) and then sends the resulting code (or data) to Controller. At last, Controller sends the final data to client browser as HTTP Response completing the entire process of data-flow.

Controller File

This is a simple PHP file with a number of “include”s (PHP statements) and a control flow defining the entire execution path. In case of scenarios facilitating large concurrent user accesses to the web application, there may be multiple Controller files (multiple entry points!). Also, Controller file acts as a public URL or a private (or password protected) URL as the situation demands.

A Controller file may be constructed with the following steps:

  1. Declare special PHP environment setting, if any (these are particularly php.ini directive(s))
  2. Start Session with the line session_start();
  3. Include configuration settings, database abstraction class, and any other common class/”include” files to be used for application.
  4. Verify HTTP Request; aggregate and assemble execution parameters from HTTP Request.
  5. Authenticate user, and assign user roles by calling Model object. Please refer to the web page describing management of user roles and system privileges through a simple Role-Based Access Control (RBAC) scheme.
  6. Code a control flow with the help of execution parameters (module parameters, event parameters, and session data – elaborated further below), and call Model objects (Model is explained in a separate section below) and View objects (View is explained in a separate section below) in the order to facilitate data-flow.

Control flow is created with the help of switch…case or if…else or combination of both. The values of module parameters determine the major white-box path in the script. On the other hand, the values of event parameters determine action to be taken based on the particular user scenario. Both of these categories of parameters originate in $_REQUEST super-global variable, and can be more than one in number in each category.

The third category of execution parameters are available in $_SESSION super-global variable. These parameters are mostly responsible for remembering the persistent state of User object and Application objects during the entire period a single session of user interaction with the application (period between login and logout by an user).

Model

Model classes are written to manage and to regulate the flow of data during the execution of business logic in the application. These classes ae instantiated in the Controller file, and are invoked by public methods therein. The model class files may reside in the /lib directory.

View

View objects (set of files, and not object technically) are basically (X)HTML files containing PHP print statements or simple conditional and loop statements spread within the HTML code. They are included from within the Controller file(s). The View files reside in the /gui/html directory.

Library Classes & Includes

These classes include DB abstraction layer, form validation and emailing classes (or we may use PEAR library too), and all common “include” statements -- usually additional functions which are still loitering outside the OO structures.

Configuration File (config.inc.php)

This file contains all global parameters like database connection values, magic numbers, and constants.

(Updated on February 01, 2007)

Get Download Files Review Project Dashboard Know Plan And Wishlist