SlideShare a Scribd company logo
1 of 19
Download to read offline
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

Codeigniter simple explanation
Codeigniter simple explanation Codeigniter simple explanation
Codeigniter simple explanation Arumugam P
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015Hossein Zahed
 
MVC Architecture in ASP.Net By Nyros Developer
MVC Architecture in ASP.Net By Nyros DeveloperMVC Architecture in ASP.Net By Nyros Developer
MVC Architecture in ASP.Net By Nyros DeveloperNyros Technologies
 
Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantAsp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantNitin Sawant
 
Code igniter overview
Code igniter overviewCode igniter overview
Code igniter overviewumesh patil
 
ColdFusion framework comparison
ColdFusion framework comparisonColdFusion framework comparison
ColdFusion framework comparisonVIkas Patel
 
C#.net applied OOP - Batch 3
C#.net applied OOP - Batch 3C#.net applied OOP - Batch 3
C#.net applied OOP - Batch 3Md. Mahedee Hasan
 
Mortal Kombat! ASP.NET MVC vs ASP.NET Webforms – ASP.NET MVC is amazing
Mortal Kombat! ASP.NET MVC vs ASP.NET Webforms – ASP.NET MVC is amazingMortal Kombat! ASP.NET MVC vs ASP.NET Webforms – ASP.NET MVC is amazing
Mortal Kombat! ASP.NET MVC vs ASP.NET Webforms – ASP.NET MVC is amazingTom Walker
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentationBhavin Shah
 
Structuring web applications with Backbone.js
Structuring web applications with Backbone.jsStructuring web applications with Backbone.js
Structuring web applications with Backbone.jsDiego Cardozo
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentationivpol
 
Dot net interview questions and asnwers
Dot net interview questions and asnwersDot net interview questions and asnwers
Dot net interview questions and asnwerskavinilavuG
 
Asp.net MVC training session
Asp.net MVC training sessionAsp.net MVC training session
Asp.net MVC training sessionHrichi Mohamed
 

What's hot (20)

Codeigniter simple explanation
Codeigniter simple explanation Codeigniter simple explanation
Codeigniter simple explanation
 
ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015ASP.NET MVC 5 - EF 6 - VS2015
ASP.NET MVC 5 - EF 6 - VS2015
 
MVC Architecture in ASP.Net By Nyros Developer
MVC Architecture in ASP.Net By Nyros DeveloperMVC Architecture in ASP.Net By Nyros Developer
MVC Architecture in ASP.Net By Nyros Developer
 
Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin SawantAsp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin Sawant
 
Code igniter overview
Code igniter overviewCode igniter overview
Code igniter overview
 
ASP .NET MVC - best practices
ASP .NET MVC - best practicesASP .NET MVC - best practices
ASP .NET MVC - best practices
 
ColdFusion framework comparison
ColdFusion framework comparisonColdFusion framework comparison
ColdFusion framework comparison
 
C#.net applied OOP - Batch 3
C#.net applied OOP - Batch 3C#.net applied OOP - Batch 3
C#.net applied OOP - Batch 3
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
Mvc
MvcMvc
Mvc
 
Mortal Kombat! ASP.NET MVC vs ASP.NET Webforms – ASP.NET MVC is amazing
Mortal Kombat! ASP.NET MVC vs ASP.NET Webforms – ASP.NET MVC is amazingMortal Kombat! ASP.NET MVC vs ASP.NET Webforms – ASP.NET MVC is amazing
Mortal Kombat! ASP.NET MVC vs ASP.NET Webforms – ASP.NET MVC is amazing
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
 
Asp.netmvc handson
Asp.netmvc handsonAsp.netmvc handson
Asp.netmvc handson
 
Structuring web applications with Backbone.js
Structuring web applications with Backbone.jsStructuring web applications with Backbone.js
Structuring web applications with Backbone.js
 
ASP .Net MVC 5
ASP .Net MVC 5ASP .Net MVC 5
ASP .Net MVC 5
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
Oop principles
Oop principlesOop principles
Oop principles
 
Dot net interview questions and asnwers
Dot net interview questions and asnwersDot net interview questions and asnwers
Dot net interview questions and asnwers
 
Django
DjangoDjango
Django
 
Asp.net MVC training session
Asp.net MVC training sessionAsp.net MVC training session
Asp.net MVC training session
 

Viewers also liked

Application SUNNY
Application SUNNYApplication SUNNY
Application SUNNYromanucci
 
Elba martinez work group vs work team
Elba martinez work group vs work teamElba martinez work group vs work team
Elba martinez work group vs work teamLio Schulze
 
conic section part 8 of 8
conic section part 8 of 8conic section part 8 of 8
conic section part 8 of 8majjisatish
 
Application ULV
Application ULVApplication ULV
Application ULVromanucci
 

Viewers also liked (8)

Application SUNNY
Application SUNNYApplication SUNNY
Application SUNNY
 
Ng briefing doc 1 june 12
Ng briefing doc 1 june 12Ng briefing doc 1 june 12
Ng briefing doc 1 june 12
 
KCM Shifttothesmartzone
KCM ShifttothesmartzoneKCM Shifttothesmartzone
KCM Shifttothesmartzone
 
Elba martinez work group vs work team
Elba martinez work group vs work teamElba martinez work group vs work team
Elba martinez work group vs work team
 
conic section part 8 of 8
conic section part 8 of 8conic section part 8 of 8
conic section part 8 of 8
 
Application ULV
Application ULVApplication ULV
Application ULV
 
Prodhimi akullores
Prodhimi akulloresProdhimi akullores
Prodhimi akullores
 
Prodhimi pastave
Prodhimi pastaveProdhimi pastave
Prodhimi pastave
 

Similar to PHP and MVC at Bar Camp Texas 2008

MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Railscodeinmotion
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applicationshchen1
 
Introduction to MVC Web Framework with CodeIgniter
Introduction to MVC Web Framework with CodeIgniterIntroduction to MVC Web Framework with CodeIgniter
Introduction to MVC Web Framework with CodeIgniterPongsakorn U-chupala
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesUlrich Krause
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Thomas Robbins
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCUlrich Krause
 
Getting Started with Spring Framework
Getting Started with Spring FrameworkGetting Started with Spring Framework
Getting Started with Spring FrameworkEdureka!
 
Spring tutorials
Spring tutorialsSpring tutorials
Spring tutorialsTIB Academy
 
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009ken.egozi
 
IRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET Journal
 
Asp.net c# MVC-5 Training-Day-1 of Day-9
Asp.net c# MVC-5 Training-Day-1 of Day-9Asp.net c# MVC-5 Training-Day-1 of Day-9
Asp.net c# MVC-5 Training-Day-1 of Day-9AHM Pervej Kabir
 
PHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterPHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterKHALID C
 

Similar to PHP and MVC at Bar Camp Texas 2008 (20)

MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Rails
 
CG_CS25010_Lecture
CG_CS25010_LectureCG_CS25010_Lecture
CG_CS25010_Lecture
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
Introduction to MVC Web Framework with CodeIgniter
Introduction to MVC Web Framework with CodeIgniterIntroduction to MVC Web Framework with CodeIgniter
Introduction to MVC Web Framework with CodeIgniter
 
An Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPagesAn Introduction To Model  View  Controller In XPages
An Introduction To Model  View  Controller In XPages
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVC
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Getting Started with Spring Framework
Getting Started with Spring FrameworkGetting Started with Spring Framework
Getting Started with Spring Framework
 
Spring tutorials
Spring tutorialsSpring tutorials
Spring tutorials
 
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
Monorail presentation at WebDevelopersCommunity, Feb 1, 2009
 
IRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHP
 
MVC Framework
MVC FrameworkMVC Framework
MVC Framework
 
Asp.net c# MVC-5 Training-Day-1 of Day-9
Asp.net c# MVC-5 Training-Day-1 of Day-9Asp.net c# MVC-5 Training-Day-1 of Day-9
Asp.net c# MVC-5 Training-Day-1 of Day-9
 
PHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniterPHP Frameworks and CodeIgniter
PHP Frameworks and CodeIgniter
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
 
Php Framework
Php FrameworkPhp Framework
Php Framework
 
Php framework
Php frameworkPhp framework
Php framework
 
Asp 1a-aspnetmvc
Asp 1a-aspnetmvcAsp 1a-aspnetmvc
Asp 1a-aspnetmvc
 
Aspnetmvc 1
Aspnetmvc 1Aspnetmvc 1
Aspnetmvc 1
 

Recently uploaded

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingThe Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingSelcen Ozturkcan
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Recently uploaded (20)

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingThe Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

PHP and MVC at Bar Camp Texas 2008

  • 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!