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 Data source backed
     MySQL, MSSQL, Web Service, 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/value0/arg1/…/valuen
   Initializes proper controller
   Executes correct method
   Facilitates communication from controller to view
   Signals view to render
Directory Structure

   Outside of web root. More secure! (generally)
   config/
   controllers/
   models/
   views/
     Usually not PHP files
 includes/
     Any extra libraries, e.g. PHPMailer
 framework/
     Framework system files (do not have to reside in
      application)
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, 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.
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

Planbox Backbone MVC
Planbox Backbone MVCPlanbox Backbone MVC
Planbox Backbone MVCAcquisio
 
3-TIER ARCHITECTURE IN ASP.NET MVC
3-TIER ARCHITECTURE IN ASP.NET MVC3-TIER ARCHITECTURE IN ASP.NET MVC
3-TIER ARCHITECTURE IN ASP.NET MVCMohd Manzoor Ahmed
 
JSP - Part 2 (Final)
JSP - Part 2 (Final) JSP - Part 2 (Final)
JSP - Part 2 (Final) Hitesh-Java
 
Spring MVC
Spring MVCSpring MVC
Spring MVCyuvalb
 
Local storage in Web apps
Local storage in Web appsLocal storage in Web apps
Local storage in Web appsIvano Malavolta
 
Modularize JavaScript with RequireJS
Modularize JavaScript with RequireJSModularize JavaScript with RequireJS
Modularize JavaScript with RequireJSMinh Hoang
 
Magento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentMagento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentIvan Chepurnyi
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleKaty Slemon
 
Implicit objects advance Java
Implicit objects advance JavaImplicit objects advance Java
Implicit objects advance JavaDarshit Metaliya
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Tuna Tore
 
MVC Puree - Approaches to MVC with Umbraco
MVC Puree - Approaches to MVC with UmbracoMVC Puree - Approaches to MVC with Umbraco
MVC Puree - Approaches to MVC with UmbracoAndy Butland
 

What's hot (20)

Planbox Backbone MVC
Planbox Backbone MVCPlanbox Backbone MVC
Planbox Backbone MVC
 
Getting started with angular js
Getting started with angular jsGetting started with angular js
Getting started with angular js
 
19servlets
19servlets19servlets
19servlets
 
3-TIER ARCHITECTURE IN ASP.NET MVC
3-TIER ARCHITECTURE IN ASP.NET MVC3-TIER ARCHITECTURE IN ASP.NET MVC
3-TIER ARCHITECTURE IN ASP.NET MVC
 
JSP - Part 2 (Final)
JSP - Part 2 (Final) JSP - Part 2 (Final)
JSP - Part 2 (Final)
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Codegnitorppt
CodegnitorpptCodegnitorppt
Codegnitorppt
 
Jsp chapter 1
Jsp chapter 1Jsp chapter 1
Jsp chapter 1
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Why Django for Web Development
Why Django for Web DevelopmentWhy Django for Web Development
Why Django for Web Development
 
Local storage in Web apps
Local storage in Web appsLocal storage in Web apps
Local storage in Web apps
 
Modularize JavaScript with RequireJS
Modularize JavaScript with RequireJSModularize JavaScript with RequireJS
Modularize JavaScript with RequireJS
 
Implicit object.pptx
Implicit object.pptxImplicit object.pptx
Implicit object.pptx
 
Magento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentMagento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module development
 
Laravel 8 export data as excel file with example
Laravel 8 export data as excel file with exampleLaravel 8 export data as excel file with example
Laravel 8 export data as excel file with example
 
WordPress and Ajax
WordPress and AjaxWordPress and Ajax
WordPress and Ajax
 
Implicit objects advance Java
Implicit objects advance JavaImplicit objects advance Java
Implicit objects advance Java
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
MVC Puree - Approaches to MVC with Umbraco
MVC Puree - Approaches to MVC with UmbracoMVC Puree - Approaches to MVC with Umbraco
MVC Puree - Approaches to MVC with Umbraco
 

Viewers also liked

Djangocon 09 Presentation - Pluggable Applications
Djangocon 09 Presentation - Pluggable ApplicationsDjangocon 09 Presentation - Pluggable Applications
Djangocon 09 Presentation - Pluggable ApplicationsNowell Strite
 
CodeIgniter - PHP MVC Framework by silicongulf.com
CodeIgniter - PHP MVC Framework by silicongulf.comCodeIgniter - PHP MVC Framework by silicongulf.com
CodeIgniter - PHP MVC Framework by silicongulf.comChristopher Cubos
 
The Agile Process - Taming Your Process To Work For You
The Agile Process - Taming Your Process To Work For YouThe Agile Process - Taming Your Process To Work For You
The Agile Process - Taming Your Process To Work For YouNowell Strite
 
Embracing Distributed Version Control
Embracing Distributed Version ControlEmbracing Distributed Version Control
Embracing Distributed Version ControlNowell Strite
 
ACL in CodeIgniter
ACL in CodeIgniterACL in CodeIgniter
ACL in CodeIgnitermirahman
 
Introduction To CodeIgniter
Introduction To CodeIgniterIntroduction To CodeIgniter
Introduction To CodeIgniterschwebbie
 
RESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkRESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkBo-Yi Wu
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to PythonNowell Strite
 

Viewers also liked (8)

Djangocon 09 Presentation - Pluggable Applications
Djangocon 09 Presentation - Pluggable ApplicationsDjangocon 09 Presentation - Pluggable Applications
Djangocon 09 Presentation - Pluggable Applications
 
CodeIgniter - PHP MVC Framework by silicongulf.com
CodeIgniter - PHP MVC Framework by silicongulf.comCodeIgniter - PHP MVC Framework by silicongulf.com
CodeIgniter - PHP MVC Framework by silicongulf.com
 
The Agile Process - Taming Your Process To Work For You
The Agile Process - Taming Your Process To Work For YouThe Agile Process - Taming Your Process To Work For You
The Agile Process - Taming Your Process To Work For You
 
Embracing Distributed Version Control
Embracing Distributed Version ControlEmbracing Distributed Version Control
Embracing Distributed Version Control
 
ACL in CodeIgniter
ACL in CodeIgniterACL in CodeIgniter
ACL in CodeIgniter
 
Introduction To CodeIgniter
Introduction To CodeIgniterIntroduction To CodeIgniter
Introduction To CodeIgniter
 
RESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP FrameworkRESTful API Design & Implementation with CodeIgniter PHP Framework
RESTful API Design & Implementation with CodeIgniter PHP Framework
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 

Similar to PHP & MVC

Conquering Gef Part 1: Effectively creating a well designed graphical editor
Conquering Gef Part 1: Effectively creating a well designed graphical editorConquering Gef Part 1: Effectively creating a well designed graphical editor
Conquering Gef Part 1: Effectively creating a well designed graphical editorVineet Sinha
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applicationshchen1
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCUlrich Krause
 
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
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code IgniterAmzad Hossain
 
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
 
ASP.net MVC CodeCamp Presentation
ASP.net MVC CodeCamp PresentationASP.net MVC CodeCamp Presentation
ASP.net MVC CodeCamp Presentationbuildmaster
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to conceptsAbhishek Sur
 
Catalyst - refactor large apps with it and have fun!
Catalyst - refactor large apps with it and have fun!Catalyst - refactor large apps with it and have fun!
Catalyst - refactor large apps with it and have fun!mold
 
Rapid Prototyping With J Query
Rapid Prototyping With J QueryRapid Prototyping With J Query
Rapid Prototyping With J QueryBootstrap
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application developmentzonathen
 
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVCApplying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVCMohamed Meligy
 

Similar to PHP & MVC (20)

Asp.Net Mvc Dev Days09
Asp.Net Mvc Dev Days09Asp.Net Mvc Dev Days09
Asp.Net Mvc Dev Days09
 
Php and-mvc
Php and-mvcPhp and-mvc
Php and-mvc
 
Conquering Gef Part 1: Effectively creating a well designed graphical editor
Conquering Gef Part 1: Effectively creating a well designed graphical editorConquering Gef Part 1: Effectively creating a well designed graphical editor
Conquering Gef Part 1: Effectively creating a well designed graphical editor
 
Mvc
MvcMvc
Mvc
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
MWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVCMWLUG 2015 - An Introduction to MVC
MWLUG 2015 - An Introduction to MVC
 
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
 
Dust.js
Dust.jsDust.js
Dust.js
 
Introduction To Code Igniter
Introduction To Code IgniterIntroduction To Code Igniter
Introduction To Code Igniter
 
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
 
Coding the UI
Coding the UICoding the UI
Coding the UI
 
Coding Ui
Coding UiCoding Ui
Coding Ui
 
ASP.net MVC CodeCamp Presentation
ASP.net MVC CodeCamp PresentationASP.net MVC CodeCamp Presentation
ASP.net MVC CodeCamp Presentation
 
ASP.NET MVC Zero to Hero
ASP.NET MVC Zero to HeroASP.NET MVC Zero to Hero
ASP.NET MVC Zero to Hero
 
Angular JS, A dive to concepts
Angular JS, A dive to conceptsAngular JS, A dive to concepts
Angular JS, A dive to concepts
 
MVC Framework
MVC FrameworkMVC Framework
MVC Framework
 
Catalyst - refactor large apps with it and have fun!
Catalyst - refactor large apps with it and have fun!Catalyst - refactor large apps with it and have fun!
Catalyst - refactor large apps with it and have fun!
 
Rapid Prototyping With J Query
Rapid Prototyping With J QueryRapid Prototyping With J Query
Rapid Prototyping With J Query
 
Intro to mobile web application development
Intro to mobile web application developmentIntro to mobile web application development
Intro to mobile web application development
 
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVCApplying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
Applying Domain Driven Design on Asp.net MVC – Part 1: Asp.net MVC
 

More from Chris Weldon

REST Easy - Building RESTful Services in Zend Framework
REST Easy - Building RESTful Services in Zend FrameworkREST Easy - Building RESTful Services in Zend Framework
REST Easy - Building RESTful Services in Zend FrameworkChris Weldon
 
Beyond TDD: Enabling Your Team to Continuously Deliver Software
Beyond TDD: Enabling Your Team to Continuously Deliver SoftwareBeyond TDD: Enabling Your Team to Continuously Deliver Software
Beyond TDD: Enabling Your Team to Continuously Deliver SoftwareChris Weldon
 
SOLID - Not Just a State of Matter, It's Principles for OO Propriety
SOLID - Not Just a State of Matter, It's Principles for OO ProprietySOLID - Not Just a State of Matter, It's Principles for OO Propriety
SOLID - Not Just a State of Matter, It's Principles for OO ProprietyChris Weldon
 
Unit Testing in SharePoint 2010
Unit Testing in SharePoint 2010Unit Testing in SharePoint 2010
Unit Testing in SharePoint 2010Chris Weldon
 

More from Chris Weldon (7)

Keat presentation
Keat presentationKeat presentation
Keat presentation
 
REST Easy - Building RESTful Services in Zend Framework
REST Easy - Building RESTful Services in Zend FrameworkREST Easy - Building RESTful Services in Zend Framework
REST Easy - Building RESTful Services in Zend Framework
 
Beyond TDD: Enabling Your Team to Continuously Deliver Software
Beyond TDD: Enabling Your Team to Continuously Deliver SoftwareBeyond TDD: Enabling Your Team to Continuously Deliver Software
Beyond TDD: Enabling Your Team to Continuously Deliver Software
 
SOLID - Not Just a State of Matter, It's Principles for OO Propriety
SOLID - Not Just a State of Matter, It's Principles for OO ProprietySOLID - Not Just a State of Matter, It's Principles for OO Propriety
SOLID - Not Just a State of Matter, It's Principles for OO Propriety
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
Unit Testing in SharePoint 2010
Unit Testing in SharePoint 2010Unit Testing in SharePoint 2010
Unit Testing in SharePoint 2010
 
IoC with PHP
IoC with PHPIoC with PHP
IoC with PHP
 

Recently uploaded

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

PHP & 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 Data source backed  MySQL, MSSQL, Web Service, 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/value0/arg1/…/valuen  Initializes proper controller  Executes correct method  Facilitates communication from controller to view  Signals view to render
  • 14. Directory Structure  Outside of web root. More secure! (generally)  config/  controllers/  models/  views/  Usually not PHP files  includes/  Any extra libraries, e.g. PHPMailer  framework/  Framework system files (do not have to reside in application)
  • 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, 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.
  • 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!