Docsity

Model – View – Controller Introduction, Lecture notes of Web Application Development

Partial preview of the text

Download Model – View – Controller Introduction and more Lecture notes Web Application Development in PDF only on Docsity!

MVC Introduction

Model – View – Controller

  • MVC Concepts - MVC Pattern Explained
    • Overview, Purpose
  • Web App Structure
    • Front Controller
    • Data Processing Table of Contents 2

MVC Concept Explained User /Some/Page/

Controller

HTTP Request

Front controller

(dispatcher)

Model

(data)

View

(render UI)

HTTP Response Delegate request Select view & pass data Use data from the model CRUD operation s

  • Design pattern with three independent components:
    • Model (data)
      • Manages data and database logic
    • View (UI)
      • Presentation layer (renders the UI)
    • Controller (logic)
      • Implements the application logic
      • Processes user request, performs an action , updates the data model and invokes a view to render some UI The MVC Pattern 5
  • Defines how the application’s user interface (UI) will be

displayed

  • May support master views (layouts)
  • May support sub-views (partial views or controls)
  • May use templates to dynamically generate HTML View (UI) 7
  • The core MVC component – holds the logic
  • Process the requests with the help of views and models
  • A set of classes that handles
    • Communication from the user
    • Overall application flow
    • Application-specific logic (business logic)
  • Every controller has one or more "actions" Controller (Logic) 8

Web and PHP App Architecture 10 Views: HTML + PHP PHP Model Classes PHP Data Access Classes Web Browser MySQL PHP Controller Classes Presentation Business Logic Data Access Layer Web Browser Database Presentation Logic

MVC Collaboration Diagram

Simple MVC Folder Structure

index.php

Book.php

Model.php

viewbook.php

Booklist Page