Model View Controller.

Slides:



Advertisements
Similar presentations
Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
Advertisements

Model View Controller Bayu Priyambadha, S.Kom. PHP & MVC  The model view controller patternis the most used pattern fortoday’s world web applications.
Multiple Tiers in Action
Struts. Agenda Preface Struts and its components An example The architecture required for Struts Applications.
UNIT-V The MVC architecture and Struts Framework.
Web Development Methodologies Yuan Wang(yw2326). Basic Concepts Browser/Server (B/S) Structure Keywords: Browser, Server Examples: Websites Client/Server.
Dataface API Essentials Steve Hannah Web Lite Solutions Corp.
FUNCTIONS AND STORED PROCEDURES & FUNCTIONS AND PROTECTING A DB AND PHP (Chapters 9, 15, 18)
Lecture 19 Web Application Frameworks Boriana Koleva Room: C54
Standalone Java Application vs. Java Web Application
1 Dr Alexiei Dingli Web Science Stream Introducing Rails.
Zend Framework Quick start Faheem Abbas Software engineer.
Pemrograman Web MVC Programming and Design Pattern in PHP 5.
3-Tier Web Application Architecture. Simple Log-in public String button1_action() { // TODO: Process the button click action. Return value is a navigation.
Intro to PHP Carl-Erik Svensson. What is PHP? PHP is a widely-used general-purpose scripting language that is especially suited for Web development and.
Model View Controller. Tipe framework yang dominan: MVC Framework yang berdasarkan MVC membagi komponen dalam 3 bagian – Model, View, Controller Controller.
CS 4720 Model-View-Controller CS 4720 – Web & Mobile Systems.
Martin Kruliš by Martin Kruliš (v1.1)1.
 An essential supporting structure of any thing  A Software Framework  Has layered structure ▪ What kind of functions and how they interrelate  Has.
Mr. Justin “JET” Turner CSCI 3000 – Fall 2015 CRN Section A – TR 9:30-10:45 CRN – Section B – TR 5:30-6:45.
Zend Framework. What is the Zend Framework? Zend Framework is a high quality and open source framework for developing Web Applications and Web Services.
APACHE STRUTS ASHISH SINGH TOMAR ast2124. OUTLINE Introduction The Model-View-Controller Design Pattern Struts’ implementation of the MVC Pattern Additional.
CS320 Web and Internet Programming Web Application and MVC Chengyu Sun California State University, Los Angeles.
Thomas Burleson. Using MVC with Flex & Coldfusion Projects June 27, 2007 See how Coldfusion MVC is similar to Flex MVC…
PHP AND SQL SERVER: CONNECTION IST 210: Organization of Data IST210 1.
Presentation Title Subheading goes here.
Dive into web development
Book Recommendation Display
Intro to HTML CS 1150 Spring 2017.
Form Data (part 2) MIS 3502, Fall 2015 Jeremy Shafer Department of MIS
Pemrograman WEB I Pertemuan 4.
Intro to HTML CS 1150 Fall 2016.
Introduction to Dynamic Web Programming
MVC Architecture, Symfony Framework for PHP Web Apps
PHP with HTML.
Uppingham Community College
PHP: Inserting data FdSc Module 109 Server side scripting and
Play Framework: Introduction
PHP Arrays Functions.
Introduction to CodeIgniter (CI)
MVC and other n-tier Architectures
Content Management System
Introduction to MVC PHP Web Development Ivan Yonkov Training Manager
Unit 6-Chapter 2 Struts.
How to get data from a form
Presentation Title Subheading goes here.
Intro to PHP & Variables
PHP: Output Formatting
Model View Controller Bayu Priyambadha, S.Kom.
MVC Framework, in general.
PHP + Oracle = Data-Driven Websites
Web Browser server client 3-Tier Architecture Apache web server PHP
Web Application Architectures
Class05 How to get data from a form
Web Applications Best Practices
PHP: Database Basic Selection FdSc Module 109
Secure Web Programming
Web Application Architectures
Software Engineering for Internet Applications
PHP an introduction.
Type your presentation title here
Unit 10 The Web Book Test.
Client-Server Model: Requesting a Web Page
Web Application Architectures
Model View Controller.
Model View Controller Bayu Priyambadha, S.Kom.
Book Recommendation Display
PHP By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and.
Struts BY: Tejashri Udavant..
Presentation transcript:

Model View Controller

Tipe framework yang dominan: MVC Framework yang berdasarkan MVC membagi komponen dalam 3 bagian – Model, View, Controller DB Model HTML, CSS, Templates Controller Template

PHP & MVC The model view controller pattern is the most used pattern for today’s world web applications It has been used for the first time in Smalltalk and then adopted and popularized by Java At present there are more than a dozen PHP web frameworks based on MVC pattern

PHP & MVC The model is responsible to manage the data The view (presentation) is responsible to display the data provided by the model in a specific format The controller handles the model and view layers to work together PHP & MVC

PHP & MVC

PHP & MVC

model/Book.php <?php class Book { public $title; public $author; public $description; public function __construct($title, $author, $description) { $this->title = $title; $this->author = $author; $this->description = $description; } ?>

model/Model.php <?php include_once("model/Book.php"); class Model { public function getBookList() { // here goes some hardcoded values to simulate the database return array( "Jungle Book" => new Book("Jungle Book", "R. Kipling", "A classic book."), "Moonwalker" => new Book("Moonwalker", "J. Walker", ""), "PHP for Dummies" => new Book("PHP for Dummies", "Some Smart Guy", "") ); } public function getBook($title) // we use the previous function to get all the books // and then we return the requested one. // in a real life scenario this will be done through // a database select command $allBooks = $this->getBookList(); return $allBooks[$title]; ?>

view/viewbook.php <html> <head></head> <body> echo 'Title:' . $book->title . '<br/>'; echo 'Author:' . $book->author . '<br/>'; echo 'Description:' . $book->description . '<br/>'; ?> </body> </html>

view/booklist.php <html> <head></head> <body> <table> <tbody> <tr><td>Title</td><td>Author</td><td>Description</td></tr> </tbody> <?php foreach ($books as $book) { echo '<tr><td><a href="index.php?book=' . $book->title . '">' . $book->title . '</a></td><td>' . $book->author . '</td><td>' . $book->description . '</td></tr>'; } ?> </table> </body> </html>

controller/Controller.php <?php include_once("model/Model.php"); class Controller { public $model; public function __construct() { $this->model = new Model(); }

controller/Controller.php public function invoke() { if (!isset($_GET['book'])) // no special book is requested, we'll show a list of all available books $books = $this->model->getBookList(); include 'view/booklist.php'; } else // show the requested book $book = $this->model->getBook($_GET['book']); include 'view/viewbook.php'; ?>

index.php <?php // All interaction goes through the index and is forwarded // directly to the controller include_once("controller/Controller.php"); $controller = new Controller(); $controller->invoke(); ?>

PHP & MVC