MVC concept in Web Development

MVC concept in Web Development

In case web development, we often hear about MVC. What is MVC? That abbreviation of Model – View – Controller concept. Smalltalk Programmer Trygve Reenskaug created this concept in 1979, long time ago before internet booming era. The program architecture significantly different than

procedural programming. Many people said MVC have advantage make program more efficient and secure.

let’s take a look inside a MVC Architecture, which basically consist of three main part ( in separate folder ) and connected each other :

mvc works

  1. VIEW

This is place where the web part visible to user, view attached to model where required to get some data update. You can set up style , color and size by include css in this part.

View example :

Class View {
    private $ymodel;
    private $xcontroller;

    public function _construct(Controller $xcontrol, Model $ymodel) {
        $this->controller = $xcontroller;
        $this->model = $ymodels;
    }

    public function display(){
        return '<i><b>'.$this->model->text.'</b></i>';
    }
}
  1. CONTROLLER

That is handle event from view, but this is not media between view and model. Although receive user’s input and send commands to model for update data, view get their own data from model.

Controller example:

class Controller

{

private $zmodel;

public function _construct(Model $zmodel)

{

$this->model=$zmodel;

}

}

model view controller
    1. MODEL

This most complex part of MVC, store data which required by view. in other word, you can call it skeleton of program. The HTML or other main data like text you can put here

Model Example :

class Model

{

public $word;

public function _construct()

{

$this->word = ‘ Hello world’;

}

}

and finally

$model = new Model();

$controller = new Controller($zmodel);

$view = new View($xcontroller, $ymodel);

echo $view->output();

laravel symfony code igniter

MVC implementation not only in php, but in other language like java, ASP or other. Especially for web development, this concept used by all frameworks like codeigniter, laravel, zend framework, symphony.