DotKernel PSR-7 Middleware Applications

HMVC structure

This post refers to DotKernel 1, based on Zend Framework 1.
If you are looking for DotKernel 3 related posts, go here.

HMVC stands for Hierarchical Model View Controller. HMVC is an evolution of the MVC pattern. The DotKernel structure is based on HMVC. When defining the DotKernel structure, we use module and dots terminology.

Below is the HMVC schema used in DotKernel:

Hierarchical Model View Controller

Hierarchical Model View Controller

Module is the first hierarchical level of a web application. Each module is composed of multiple dots. Before we go further, read about the module and dots structures to understand the above schema.

Each module has its own unique controller: Front ControllerIndexController. It handles all requests for the selected module, deciding what happens next – which dots should be called.

A dots is made up of MVC files and the xml configuration file. The Front Controller routes the request to the Action Controller.

The Action Controller is the heart of the MVC. The Action Controller controls the flow, makes requests to Model, View or facilitates communication between them.

Inside the Model, we have all the items related to the data

  • methods to retrieve data from the DataStorage(database)
  • methods to manipulate the data that comes into or out of the DataStorage

The View is in charge of the GUI (Graphic User Interface) of the application. The View is composed from PHP, TPL and JS file types. Note that each module has a View , and the dots View class extends the module View .

From the View , the flow is going back to the IndexController outputting the response to the user.

To make it clearer, let’s take an example:

  • Module: frontend, admin.
  • In the frontend module:
    • Front Controllercontrollers/frontend/IndexController.php
    • dots: Page, User
  • The MVC structure of User dotsis:
    • Action Controllercontrollers/frontend/UserController.php
    • ModelDotKernel/ frontend /User.php
    • ViewDotKernel/frontend/views/UserView.php, class extends DotKernel/frontend/View.php
  • xml configsconfigs/dots/user.xml
  • templates templates/ frontend /user/*.tpl
  • javascript templates/js/frontend/user.js