InstantCMS is a modular system developed on the MVC architecture.
Modular blocks, of which the site’s features are composed, are called Components in InstantCMS.
A controller is the main part of the component in which all business logic is located. The purpose of a controller is to receive a request from a user, process it and return the result (for example, an HTML-page or JSON).
Each component may have 2 controllers - frontend and backend that work in user and admin parts of the site correspondingly.
A model is a part of a component and contains the logic of extracting, editing and saving the data. The model receives the requests from a controller and returns the results from the database to it, or vice versa, saves the changes in the database.
Templates are meant for formatting the data before displaying it to a user. The template contains an HTML-markup and a minimum of code - only to the extent necessary to format the output. The data is passed to the template by a controller.
Each user’s request (opening a page in a browser) initiates the following working process:
- index.php file is launched;
- Router defines which component was requested and launches its controller;
- Controller receives the request parameters from a URL or a form filled by a user;
- Controller receives (or saves) the data via model;
- Controller processes the data in a proper way;
- Controller requests the template and passes the received (or processed) data into it;
- Template forms the final HTML-page that is returned to a user.
Thus, the main logic (a greater part of the code) is located inside the controller.
In the next documentation sections, we are going to consider the structure of controllers, models and templates in more detail.