MVC architecture of CakePHP
CakePHP follows the MVC software design pattern. MVC
Programming pattern will separate the application into three parts:
- Model layer
- View layer
- Controller layer
- Model layer
- View layer
- Controller layer
The Model layer
The Model layer represents one
part of the application that implements the business logic. Models are
representations of database tables. They can connect to database, query it and
save data to the database.
In order to work with MVC its very important to
note that there must be no interaction between models and views.All the logic
will be handled by controllers.It’s responsible for fetching data and then after converting them into meaningful concepts for the application by processing,validating, associating or other similar tasks related to handling data.
MVC Request

The View layer
You can
describe Views as template files that present their content to the
user.variables, arrays and objects that are used in views are registered
through a controller.
A presentation of the modeled data will be rendered by the View.View will
produce the presentational interface for your application using the information
it has available.
For example, A set of data
returned by the Model layer, will be used by the view to render a HTML page
containing it.The View layer is not only used for HTML or text representation
of the data,but also used to deliver a wide variety of formats.Like videos,
music, documents and other format.
A presentation of the modeled data will be rendered by the View.View will produce the presentational interface for your application using the information it has available.
The Controller layer
Requests from the users are handled by the
Controller layer.Controller mainly contains the logic of your application.
Controller offers various functionalities,they retrieve the data and modify
them by accessing database tables through models.They also register the
variables and objects, that can be used in views.
You can consider the Controllers as managers taking care that all
needed resources for completing a task are delegated to the correct workers.
They wait for petitions from clients, and then checks their validity according
to the rules of authentication or authorization, processing to the model, and
selects only the correct type of presentational data which are expected by the
client ,to finally delegate this rendering process to the View layer.
They wait for petitions from clients, and then checks their validity according to the rules of authentication or authorization, processing to the model, and selects only the correct type of presentational data which are expected by the client ,to finally delegate this rendering process to the View layer.
No comments:
Post a Comment