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
Each module has its own unique controller: Front Controller – IndexController. 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 Controller – controllers/frontend/IndexController.php
- dots: Page, User
- The MVC structure of User dotsis:
- Action Controller – controllers/frontend/UserController.php
- Model- DotKernel/ frontend /User.php
- View – DotKernel/frontend/views/UserView.php, class extends DotKernel/frontend/View.php
- xml configs – configs/dots/user.xml
- templates - templates/ frontend /user/*.tpl