Wednesday, July 15, 2020

What is the Design Pattern of CakePHP 4?

CakePHP 4.0 follows the MVC (Model-View-Controller) design pattern. MVC consist on three main components. Model, View and Controller

MVC

Model

Any application which is dynamic in nature depend on data, model is the container of data.  For example, Student is a model, it contains its related data like First Name, Last Name, Roll Number and Grade. In programming languages data is encapsulated in the objects of as class. Model has a central role in MVC design pattern, whole application revolves around the model. It is used to temporary store data, validate data, and facilitate to permanently store the data in databases. In CakePHP 4.0 model is fat layer as compare to two other components.

View

View is a perspective of viewing the data graphically, it retrieves the data from model and represents on the page in HTML. For example Student may have different perspectives like its Personal Information, Its Educational Record, or its extra curriculum achievements. Each of these groups of information is handled through models and represented on screen either in tabular format or in any other graphical format like bar charts pie charts etc.

Controller

Controller is the middle layer between model and views, main objective of controller is to receive the request, arrange the data through models and handover to views for display and vice versa. In CakePHP controllers are slim layer.

Today we have seen the design pattern of CakePHP 4.0. It is important to understand the concept of MVC, because whole development of application is dependent of these three types of components. In the next article we will see the whole concept in action through the code.


0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.