Sie sind auf Seite 1von 17

A Presentation on

MVC(Model-View-Controller) Architecture

Department of Computer Science and Technology,


Technique Polytechnic Institute, Panchrokhi,
Sugandhya, Hooghly – 712012

Presented by:

Tiyasha Das (11)


Ritosom Pal (23)
Rohan Sarkar (33)
Souvik Kundu (64)
TABLE OF CONTENTS
1

 Introduction  Why MVC


 What is MVC  MVC and the Web
 History  Sites using MVC
 Define MVC  Conclusion
 As a Framework  References
INTRODUCTION
2

MVC Stands for "Model-View-Controller." MVC is an application design model


comprised of three interconnected parts. They include the model (data), the view
(user interface), and the controller (processes that handle input). The MVC model
or "pattern" is commonly used for developing modern user interfaces. It is provides
the fundamental pieces for designing a programs for desktop or mobile, as well as
web applications. It works well with object-oriented programming, since the
different models, views, and controllers can be treated as objects and reused
within an application.
WHAT IS MVC
3

 Model, View, Controller


 Object Oriented
 Is communication between Model, View, and Controller Objects
 Software Engineering
 Organization
 RAD (Rapid Application Development)
 Code reuse!
HISTORY
4

 Smalltalk-80 (circa 1980)


 MVC first discussed in 1979 by Trygve Mikkjel Heyerdahl Reenskaug
 MFC (Document/View)
 Java’s Swing
 QT4 (KDE)
 Apple’s Cocoa (Core Data)
 Notice a trend ?
 MVC is perfectly suited for GUI development..
DEFINING MVC ARCHITECTURE
5

 Model – this part is concerned with the business logic and the application data. It
can be used to perform data validations, process data and store it. The data can
come from:
 flat file
 database
 XML document
 Other valid data sources.
 This is the business layer. It helps retrieve data from the database. These are simple
class files that contain the properties.
DEFINING MVC ARCHITECTURE
6

 View – this part deals with presenting the data to the user. This is usually in form
of HTML pages.
 It is also responsible to display the data provided by the model in a specific
format. It has a similar usage with the template modules present in some popular
web applications, like wordpress, joomla, Magento, Laravel etc.
DEFINING MVC ARCHITECTURE
7

 Controller – this is the part deals with the users’ requests for resources from
the server. As an example,
when the users requests for the URL…/index.php?products=list, the controller
will load the products model to retrieve the products data then output the
results in the list view. In a nutshell, the controller links the models and views
together depending on the requested resources.
 The controller is the first thing which takes a request, parses it, initializes and
invoke the model and takes the model response and sends it to the
presentation layer. It’s practically the leant between the Model and the View, a
small framework where Model and View are plugged in. In our native php
implementation the controller is implemented by only one class, named
unexpectedly controller.
DEFINING MVC
8

CONTROLLER

SEND DATA
MODEL

USER

VIEW

MVC FRAMEWORK
MVC AS A FRAMEWORK
9

 index.php
 Parses the URL
 Often mod_rewrite used
 Initializes proper controller
 Executes correct method
 Facilitates communication from controller to view
 Signals view to render
MVC AS A FRAMEWORK
10
Directory Structure
 Outside of web root. More secure! (generally)
 config/
 controllers/
 models/
 views/
 Usually not PHP files
 includes/
 Any extra libraries, e.g. PHPMailer, Mailchimp
 framework/
 Framework system files (don’t have to reside in application)
WHY USE MVC
11

 Good architectural design


 Code is organized and structure
 Code structure lends itself to an easy to understand directory structure
 Easy code maintenance
 Because of abstraction, better strategic positioning of code will minimize the hunt for
places to change
 Easy to extend and grow
 Modify parent classes, drop in new controller, etc.
MVC AND THE WEB
12

 Made popular by Ruby on Rails


 A good number of PHP MVC frameworks are Rails inspired
 Wikipedia currently lists about 17 PHP MVC frameworks
 CakePHP
 Symfony
 Code Igniter
 Zend Framework
 Yii
 Also we can make our own architecture using MVC framework
SITES USING PHP MVC FRAMEWORKS
13

 CakePHP
 Mozilla Addons
 The Onion’s Online Store
 Symfony
 TED.com
 Yahoo! Bookmarks
 Microsoft
 Godaddy
 DELL
 Stackoverflow
 Pretty much everyone.
CONCLUSION
14

As touched on above, MVC is a really good way to begin producing clean,


scalable, powerful, fast code in the least amount of time with the least amount of
effort. Some MVC frameworks do not contain all of these features, most contain
one or two. It’s better to experiment with a few MVC frameworks and find one that
works for us.
REFERENCES
15

https://www.w3schools.com
https://www.c-sharpcorner.com
https://www.php-html.net
https://www.dzone.com
https://www.slideshare.net
https://www.wikipedia.org
https://www.google.com
THANK YOU!

Das könnte Ihnen auch gefallen