SlideShare a Scribd company logo
Daniel Cousineau & Chris Weldon
Bar Camp Texas 2008

PHP AND MVC
First Things First

     http://www.google.com/search?hl=en&q=mvc
         Google is wonderful, learn how to use it.
         Or Yahoo
         There are 6,203,493* search engines, use one
     http://www.toosweettobesour.com/
         Slides if anyone wants ‘em
     http://www.chrisweldon.net/



* Possibly incorrect
MVC Is…

 Model, View, Controller
 Object Oriented
   Is communication between Model, View, and
    Controller Objects
 Software Engineering
 Organization
 RAD
   Code reuse!
History
MVC Is Not New!

 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…
MVC And The Web

 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
     Make your own (I did!)
Define MVC
Model – View – Controller
Model

 Wikipedia:
   “The domain-specific representation of the
    information that the application operates.”
 Data Storage/Access
   Often Database backed
     MySQL, MSSQL, Postgresql, it doesn’t matter…
   Abstraction, Abstraction, Abstraction!
View

 Wikipedia:
   “Renders the model into a form suitable for
    interaction, typically a user interface element.
    Multiple views can exist for a single model for
    different purposes.”
 HTML Templates
   All formatting related code belongs here
   A Smarty object is a good example
     Any template engine works, however…
   Abstraction, Abstraction, Abstraction!
Controller

 Wikipedia:
   “Processes and responds to events, typically user
    actions, and may invoke changes on the model.”
 A BIG DEAL
   Process user inputs, communicate with Models and
    Views
     The Go-Between
   Much of the application’s core logic
   Utilize the abstraction of before!
     Invoke model, assign values to views
Putting It Together…
http://ash-mvc.org/website/framework/framework.html
As A Framework
Common Traits

 index.php
   Parses the URL
     Often mod_rewrite used:
       /controller/method/arg0/arg1/arg2/…/argn/
   Initializes proper controller
   Executes correct method
   Facilitates communication from controller to view
   Signals view to render
Directory Structure

   config/
   controllers/
   models/
   views/
     Usually just .html or .tpl files
 includes/
     Any extra libraries, e.g. PHPMailer
 framework/
     Framework system files
Helpers and Plug-ins

 Usually common functions used by Views
   E.g. format_phone(), create_calendar(),
    etc.
 Some loaded through index.php, some loaded
  specifically by controller
 Do not allow direct manipulation of models or
  controllers
   Any code requiring access to models should be in the
    controller, not view
Other Utilities…

 Dispatcher classes
   Abstract the location of files
   Abstract creation of links/connections
 Caching classes
   Cache Templates? Output? SQL Queries? Opcode
   Caching individual Templates poses a special problem
     Will dynamism of framework affect caching?
Why MVC?

 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, only have to change code
    once (usually)
 Easy to extend and grow
   Modify parent classes, drop in new controller, etc.
Sites Using PHP MVC Frameworks

 CakePHP
   Mozilla Addons
   The Onion’s Online Store
 Symfony
   TED.com
   Yahoo! Bookmarks
 Pretty much everyone.
The Cake Was NOT a Lie!

More Related Content

What's hot (20)

PPT
Codeigniter simple explanation
Arumugam P
 
PPTX
ASP.NET MVC 5 - EF 6 - VS2015
Hossein Zahed
 
PPT
MVC Architecture in ASP.Net By Nyros Developer
Nyros Technologies
 
PPTX
Asp.net mvc presentation by Nitin Sawant
Nitin S
 
PPT
Code igniter overview
umesh patil
 
PPTX
ASP .NET MVC - best practices
Bohdan Pashkovskyi
 
PPT
ColdFusion framework comparison
VIkas Patel
 
PPSX
C#.net applied OOP - Batch 3
Md. Mahedee Hasan
 
PPT
Asp.net mvc
Naga Harish M
 
ODP
Mvc
abhigad
 
PPTX
Mortal Kombat! ASP.NET MVC vs ASP.NET Webforms – ASP.NET MVC is amazing
Tom Walker
 
PPT
MVC ppt presentation
Bhavin Shah
 
PPTX
Asp.netmvc handson
Prashant Kumar
 
PDF
Structuring web applications with Backbone.js
Diego Cardozo
 
PPTX
ASP .Net MVC 5
Nilachal sethi
 
PPT
ASP.NET MVC Presentation
ivpol
 
PPSX
Oop principles
Md. Mahedee Hasan
 
PDF
Dot net interview questions and asnwers
kavinilavuG
 
PDF
Django
sisibeibei
 
PPTX
Asp.net MVC training session
Hrichi Mohamed
 
Codeigniter simple explanation
Arumugam P
 
ASP.NET MVC 5 - EF 6 - VS2015
Hossein Zahed
 
MVC Architecture in ASP.Net By Nyros Developer
Nyros Technologies
 
Asp.net mvc presentation by Nitin Sawant
Nitin S
 
Code igniter overview
umesh patil
 
ASP .NET MVC - best practices
Bohdan Pashkovskyi
 
ColdFusion framework comparison
VIkas Patel
 
C#.net applied OOP - Batch 3
Md. Mahedee Hasan
 
Asp.net mvc
Naga Harish M
 
Mvc
abhigad
 
Mortal Kombat! ASP.NET MVC vs ASP.NET Webforms – ASP.NET MVC is amazing
Tom Walker
 
MVC ppt presentation
Bhavin Shah
 
Asp.netmvc handson
Prashant Kumar
 
Structuring web applications with Backbone.js
Diego Cardozo
 
ASP .Net MVC 5
Nilachal sethi
 
ASP.NET MVC Presentation
ivpol
 
Oop principles
Md. Mahedee Hasan
 
Dot net interview questions and asnwers
kavinilavuG
 
Django
sisibeibei
 
Asp.net MVC training session
Hrichi Mohamed
 

Viewers also liked (8)

DOC
Application SUNNY
romanucci
 
PPTX
Ng briefing doc 1 june 12
businessdriver-uk
 
PDF
KCM Shifttothesmartzone
Kenjol Capital Management
 
PDF
Elba martinez work group vs work team
Lio Schulze
 
PDF
conic section part 8 of 8
majjisatish
 
DOC
Application ULV
romanucci
 
PPT
Prodhimi akullores
Ardian Kryeziu
 
PPT
Prodhimi pastave
Ardian Kryeziu
 
Application SUNNY
romanucci
 
Ng briefing doc 1 june 12
businessdriver-uk
 
KCM Shifttothesmartzone
Kenjol Capital Management
 
Elba martinez work group vs work team
Lio Schulze
 
conic section part 8 of 8
majjisatish
 
Application ULV
romanucci
 
Prodhimi akullores
Ardian Kryeziu
 
Prodhimi pastave
Ardian Kryeziu
 
Ad

Similar to Php and-mvc (20)

PDF
PHP & MVC
Chris Weldon
 
PDF
Streamlining Your Applications with Web Frameworks
guestf7bc30
 
PPTX
Ps02 cint24 mvc in php
Conestoga Collage
 
PDF
Php framework
cncwebworld
 
PPTX
Php Framework
cncwebworld
 
PDF
MVC in PHP
Vineet Kumar Saini
 
PDF
MVC development company in UK.
Techrishblogger
 
PPTX
MVC & CodeIgniter
Harshit Gupta
 
PPT
Howtobuildyourownframework
hazzaz
 
PPTX
Introduction to MVC Web Framework with CodeIgniter
Pongsakorn U-chupala
 
PDF
Presentation 1 Web--dev
altsav
 
PPTX
MVC Framework
Ashton Feller
 
PDF
IRJET- Lightweight MVC Framework in PHP
IRJET Journal
 
PDF
Developing WordPress Plugins Using the MVC Methodology
Nate Allen
 
PPT
Getting Started with Zend Framework
Juan Antonio
 
PPT
MVC(Model View Controller),Web,Enterprise,Mobile
naral
 
PPTX
4. Web programming MVC.pptx
KrisnaBayu41
 
PPTX
MVC architecture by Mohd.Awais on 18th Aug, 2017
Innovation Studio
 
PPTX
Mvc framework
Dhurham Fahem
 
PHP & MVC
Chris Weldon
 
Streamlining Your Applications with Web Frameworks
guestf7bc30
 
Ps02 cint24 mvc in php
Conestoga Collage
 
Php framework
cncwebworld
 
Php Framework
cncwebworld
 
MVC in PHP
Vineet Kumar Saini
 
MVC development company in UK.
Techrishblogger
 
MVC & CodeIgniter
Harshit Gupta
 
Howtobuildyourownframework
hazzaz
 
Introduction to MVC Web Framework with CodeIgniter
Pongsakorn U-chupala
 
Presentation 1 Web--dev
altsav
 
MVC Framework
Ashton Feller
 
IRJET- Lightweight MVC Framework in PHP
IRJET Journal
 
Developing WordPress Plugins Using the MVC Methodology
Nate Allen
 
Getting Started with Zend Framework
Juan Antonio
 
MVC(Model View Controller),Web,Enterprise,Mobile
naral
 
4. Web programming MVC.pptx
KrisnaBayu41
 
MVC architecture by Mohd.Awais on 18th Aug, 2017
Innovation Studio
 
Mvc framework
Dhurham Fahem
 
Ad

Recently uploaded (20)

PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PPT
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PDF
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
PDF
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
PPTX
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Ericsson LTE presentation SEMINAR 2010.ppt
npat3
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
ICONIQ State of AI Report 2025 - The Builder's Playbook
Razin Mustafiz
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Future-Proof or Fall Behind? 10 Tech Trends You Can’t Afford to Ignore in 2025
DIGITALCONFEX
 
Kit-Works Team Study_20250627_한달만에만든사내서비스키링(양다윗).pdf
Wonjun Hwang
 
MuleSoft MCP Support (Model Context Protocol) and Use Case Demo
shyamraj55
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 

Php and-mvc

  • 1. Daniel Cousineau & Chris Weldon Bar Camp Texas 2008 PHP AND MVC
  • 2. First Things First  http://www.google.com/search?hl=en&q=mvc  Google is wonderful, learn how to use it.  Or Yahoo  There are 6,203,493* search engines, use one  http://www.toosweettobesour.com/  Slides if anyone wants ‘em  http://www.chrisweldon.net/ * Possibly incorrect
  • 3. MVC Is…  Model, View, Controller  Object Oriented  Is communication between Model, View, and Controller Objects  Software Engineering  Organization  RAD  Code reuse!
  • 5. MVC Is Not New!  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…
  • 6. MVC And The Web  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  Make your own (I did!)
  • 7. Define MVC Model – View – Controller
  • 8. Model  Wikipedia:  “The domain-specific representation of the information that the application operates.”  Data Storage/Access  Often Database backed  MySQL, MSSQL, Postgresql, it doesn’t matter…  Abstraction, Abstraction, Abstraction!
  • 9. View  Wikipedia:  “Renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes.”  HTML Templates  All formatting related code belongs here  A Smarty object is a good example  Any template engine works, however…  Abstraction, Abstraction, Abstraction!
  • 10. Controller  Wikipedia:  “Processes and responds to events, typically user actions, and may invoke changes on the model.”  A BIG DEAL  Process user inputs, communicate with Models and Views  The Go-Between  Much of the application’s core logic  Utilize the abstraction of before!  Invoke model, assign values to views
  • 13. Common Traits  index.php  Parses the URL  Often mod_rewrite used:  /controller/method/arg0/arg1/arg2/…/argn/  Initializes proper controller  Executes correct method  Facilitates communication from controller to view  Signals view to render
  • 14. Directory Structure  config/  controllers/  models/  views/  Usually just .html or .tpl files  includes/  Any extra libraries, e.g. PHPMailer  framework/  Framework system files
  • 15. Helpers and Plug-ins  Usually common functions used by Views  E.g. format_phone(), create_calendar(), etc.  Some loaded through index.php, some loaded specifically by controller  Do not allow direct manipulation of models or controllers  Any code requiring access to models should be in the controller, not view
  • 16. Other Utilities…  Dispatcher classes  Abstract the location of files  Abstract creation of links/connections  Caching classes  Cache Templates? Output? SQL Queries? Opcode  Caching individual Templates poses a special problem  Will dynamism of framework affect caching?
  • 17. Why MVC?  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, only have to change code once (usually)  Easy to extend and grow  Modify parent classes, drop in new controller, etc.
  • 18. Sites Using PHP MVC Frameworks  CakePHP  Mozilla Addons  The Onion’s Online Store  Symfony  TED.com  Yahoo! Bookmarks  Pretty much everyone.
  • 19. The Cake Was NOT a Lie!