User Tools

Site Tools


programmieren:cakephp:mvc

This is an old revision of the document!


MVC

CakePHP uses the MVC (Model-View-Controller) design pattern. As seen by the 3 letters, wow how attentive, it is separated into 3 parts.

Model: Mostly the business logic. Stuff like Table classes, services and repositories. It retrieves necessary data or alters it. Its like the first contact point with backend structures that arent the application itsself like Databases or APIs. It can also just be used to transform data that is already within the application. So just like the main logic as previously mentioned.

View: The view layer is responsible for users being able to VIEW, no shit, the data that has been processed in the Model part. It gets a certain set of data and presents it to the user in a meaningful way. We mostly use it for forms or indices like the standard CRUD (← I should totally link this once I make an entry about crud).

Controller: The controller is like the evil ahh manager that orders the others around. It is the part that recieves a request from a user, can be over the UI or API or whatever, and coordinate a response with the Model and View. Its what checks Authentication and Authorization of the given request and makes sure the response contains everything the request needed, and if not responds accordingly. If there is a UI it makes sure the according View is rendered.

Described pretty well in the CakePHP documentation. Its outdated idk why they removed it.

In the case of CakePHP it looks like this:

programmieren/cakephp/mvc.1787033818.txt.gz · Last modified: by admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki