User Rating: 2 / 5

Star ActiveStar ActiveStar InactiveStar InactiveStar Inactive
Model View Controller (MVC) -

is a widely used software architecture pattern that informs the design of some of your favorite software applications. We will take a look at the MVC patten in some more detail, especially how it is used in PHP.


Program Flow

The typical program flow in MVC is:

  • The model, view and controller are initialised
  • The view is displayed to the user, reading data from the model
  • The user interacts with view which calls a specified controller action
  • The controller updates the model in some way
  • The view is refreshed (fetching the updated data from the model


A Model View Controller pattern is made up of the following three parts.


Model - The model is a representation of knowledge. That is, the model contains the actual data that has to be shown to the user. All data is held in a structured format. For example, the HTML on this web page holds the actual text you see inside structured HTML <tags>


View - The view is a visual representaion of the model. The view informs the way data structured in the model will be made visible to the user. For example, the HTML may hold the text, but the colors, font size and font style information is actually held by independent CSS stylesheets.


Controller - A controller is the environment that bridges the divide between the user and the system. This is the device that lets the user interact with the system. In the above examples, the browser is the controller that helps you interact with the web page.