SlideShare a Scribd company logo
 
The Current Situation Object-Oriented Introduction Basics, concepts, terminology & examples Object-Oriented Benefits Code re-use, portability, structure, meaning, control, separation of responsibility, time, reduce dependencies and more
Most scripts & tutorials all procedural or show bad understanding of OO PHP’s unique history Template language & PHP/FI 2.0 “ evolved” over time with OO features Good OO finally starting to emerge PHP5 released in 2004 Zend Framework Symfony Project
 
That was easy! Add “Object-Oriented PHP” to your resume!
It’s much more than just syntax –  It’s a mindset Object-Oriented programming gives  meaning  to your data Represents real-world objects when possible Where have we seen this before?
Semantic markup Think: <blockquote> for quotes, not indentation <address> for addresses, not <p> or <div> <cite> instead of <i> for citations Goal is to for code to  convey meaning
Create meaning and structure Separate responsibilities Reduce/Isolate dependencies Create common public interfaces Clear, self-documenting code
Code objects cannot  always  represent real-world objects Application flow Structure Delegation Separation of responsibilities How do we solve these problems? Design Patterns
Model-View-Controller (MVC) Active Record Data Mapper Adapter Registry Factory Observer
What OO programming is  not  – where many PHP projects go wrong
 
Decorator
What is User? A finder/utility class? No clear definition or purpose “ bob”  is  a User 1 instance = 1 user Properties of a user Functions of a user
The power of applying object-oriented design to your application
Objects add automatic clarity Stick to standards and naming conventions camelCase Zend Coding Standards Function naming as verbose as possible getPostBySlug($slug) findPostsWithTag($tagName)
 
 
 
Parent > Child relationship between objects Child extends Parent Child inherits all parent methods Child can override parent methods when required Changes can be reflected across your entire application with relative ease
 
Hides actual implementation Reduces or isolates dependencies to lower levels Reduces or eliminates extensive future changes in code base
Adding extra headers is a mess (CC, BCC) No built-in file attachment options Limited configuration options (Sendmail/SMTP) Very inefficient for large amounts of email
Custom Email() object Clear, descriptive syntax Unlimited configuration options  mail(), SMTP, database, external server, etc. File attachments can be easy with function
Did you notice the dependencies?
Remove the database dependencies by using a standard interface PDO provides one (bundled with PHP5) Use  dependency injection  to expose dependencies
Pass connection into constructor and store it as a class property Replace mysql_* functions with standard functions from PDO using connection
Database adapters are interchangeable
Interchangeable code components Standard interface Single dependency Separate “engine” from implementation
Different payment processors are a simple drop-in replacement
Objects should serve a single purpose Separate code into manageable chunks MVC – Good example Model – Database View – Display Controller – Request/Flow Resist temptation of globals everywhere “ global $var”, $_SESSION, $_REQUEST, etc
 
 
Building a Data Mapper with PHP5 and the Standard PHP Library Friday Oct. 10 @ 10:30am
www.php.net/php5 Full official PHP5 feature documentation Communities Sitepoint – sitepoint.com PHPit – phpit.com PHP|Architect – phparch.com Zend Developer Zone - devzone.zend.com
Vance Lucas, 23 Blog:  www.vancelucas.com Email:  [email_address] Making websites since age 12 Started learning PHP when PHP3 was new Oklahoma Baptist University – Shawee Bachelor of Business Administration Currently work at Back40 Design, Inc. www.back40design.com
 

More Related Content

PPTX
Object oriented programming
Sandeep Karthikeyan
 
DOCX
Object oriented programming tutorial
Ghulam Abbas Khan
 
PPTX
Principles and advantages of oop ppt
daxesh chauhan
 
PPTX
Characteristics of OOPS
abhishek kumar
 
PPTX
Object Oriented Programming Principles
Andrew Ferlitsch
 
PPTX
Characteristics of oop
Rasim Izhar Ali
 
PPTX
Introduction to Object Oriented Programming
Md. Tanvir Hossain
 
Object oriented programming
Sandeep Karthikeyan
 
Object oriented programming tutorial
Ghulam Abbas Khan
 
Principles and advantages of oop ppt
daxesh chauhan
 
Characteristics of OOPS
abhishek kumar
 
Object Oriented Programming Principles
Andrew Ferlitsch
 
Characteristics of oop
Rasim Izhar Ali
 
Introduction to Object Oriented Programming
Md. Tanvir Hossain
 

What's hot (20)

PDF
Object-oriented programming (OOP) with Complete understanding modules
Durgesh Singh
 
PDF
Concepts of OOPs
Essay Corp
 
PPT
Oop Presentation
Ghaffar Khan
 
PPTX
Object oriented programming
Amit Soni (CTFL)
 
PPT
OOP programming
anhdbh
 
PPTX
Oop ppt
Shani Manjara
 
PPTX
Object Oriented Programming in Java _lecture 1
Mahmoud Alfarra
 
PDF
Introduction to object oriented programming
Abzetdin Adamov
 
PPTX
Object Oriented Concept
D Nayanathara
 
PDF
Oop
志明 陳
 
PPT
Oops
Prabhu R
 
PPT
2 Object Oriented Programming
Praveen M Jigajinni
 
PPTX
principle of oop’s in cpp
gourav kottawar
 
PPTX
Introduction to Object Oriented Programming
Moutaz Haddara
 
PPTX
01 introduction to oop and java
রাকিন রাকিন
 
PPTX
OOP - Benefits and advantages of OOP
Mudasir Qazi
 
PPTX
Oo ps concepts in c++
Hemant Saini
 
PPTX
Object-Oriented concepts.pptx
BHARATH KUMAR
 
Object-oriented programming (OOP) with Complete understanding modules
Durgesh Singh
 
Concepts of OOPs
Essay Corp
 
Oop Presentation
Ghaffar Khan
 
Object oriented programming
Amit Soni (CTFL)
 
OOP programming
anhdbh
 
Oop ppt
Shani Manjara
 
Object Oriented Programming in Java _lecture 1
Mahmoud Alfarra
 
Introduction to object oriented programming
Abzetdin Adamov
 
Object Oriented Concept
D Nayanathara
 
Oops
Prabhu R
 
2 Object Oriented Programming
Praveen M Jigajinni
 
principle of oop’s in cpp
gourav kottawar
 
Introduction to Object Oriented Programming
Moutaz Haddara
 
01 introduction to oop and java
রাকিন রাকিন
 
OOP - Benefits and advantages of OOP
Mudasir Qazi
 
Oo ps concepts in c++
Hemant Saini
 
Object-Oriented concepts.pptx
BHARATH KUMAR
 
Ad

Similar to PHP - Procedural To Object-Oriented (20)

PDF
A Gentle Introduction To Object Oriented Php
Michael Girouard
 
ZIP
Object Oriented PHP5
Jason Austin
 
PDF
Introduction into PHP5 (Jeroen van Sluijs)
Stefan Koopmanschap
 
PDF
Introduction to PHP (SDPHP)
Eric Johnson
 
PPTX
Introduction to PHP and MySql basics.pptx
PriyankaKupneshi
 
PDF
OOP in PHP
Alena Holligan
 
ODP
Best practices tekx
Lorna Mitchell
 
PPTX
OOP Day 2
Brian Fenton
 
PPT
Building Data Mapper PHP5
Vance Lucas
 
PPT
PHP- Introduction to Object Oriented PHP
Vibrant Technologies & Computers
 
PPT
Introduction to PHP - SDPHP
Eric Johnson
 
DOC
Oss questions
rameshbavi
 
PDF
Professional PHP: an open-source alternative for enterprise development [Kort...
Combell NV
 
PPTX
Object oriented programming in php 5
Sayed Ahmed
 
PPTX
Object oriented programming in php 5
Sayed Ahmed
 
PPT
Phpwebdevelping
mohamed ashraf
 
PDF
Demystifying Object-Oriented Programming - PHP[tek] 2017
Alena Holligan
 
PDF
6 Months Industrial Project Training in PHP Delhi/NCR
shane99
 
PPT
PHP 5 Boot Camp
Adam Trachtenberg
 
PDF
Object Oriented Programming with Laravel - Session 1
Shahrzad Peyman
 
A Gentle Introduction To Object Oriented Php
Michael Girouard
 
Object Oriented PHP5
Jason Austin
 
Introduction into PHP5 (Jeroen van Sluijs)
Stefan Koopmanschap
 
Introduction to PHP (SDPHP)
Eric Johnson
 
Introduction to PHP and MySql basics.pptx
PriyankaKupneshi
 
OOP in PHP
Alena Holligan
 
Best practices tekx
Lorna Mitchell
 
OOP Day 2
Brian Fenton
 
Building Data Mapper PHP5
Vance Lucas
 
PHP- Introduction to Object Oriented PHP
Vibrant Technologies & Computers
 
Introduction to PHP - SDPHP
Eric Johnson
 
Oss questions
rameshbavi
 
Professional PHP: an open-source alternative for enterprise development [Kort...
Combell NV
 
Object oriented programming in php 5
Sayed Ahmed
 
Object oriented programming in php 5
Sayed Ahmed
 
Phpwebdevelping
mohamed ashraf
 
Demystifying Object-Oriented Programming - PHP[tek] 2017
Alena Holligan
 
6 Months Industrial Project Training in PHP Delhi/NCR
shane99
 
PHP 5 Boot Camp
Adam Trachtenberg
 
Object Oriented Programming with Laravel - Session 1
Shahrzad Peyman
 
Ad

More from Vance Lucas (7)

PDF
How to Evaluate Your App Idea
Vance Lucas
 
PDF
How to Build a Tech Community
Vance Lucas
 
PDF
Bullet: The Functional PHP Micro-Framework
Vance Lucas
 
PDF
Stackbox CMS: Next-Generation Content Management
Vance Lucas
 
PDF
Cross-Platform Mobile Development with Titanium
Vance Lucas
 
PDF
Alloy HMVC PHP Framework
Vance Lucas
 
PPTX
Object Oriented Apologetics
Vance Lucas
 
How to Evaluate Your App Idea
Vance Lucas
 
How to Build a Tech Community
Vance Lucas
 
Bullet: The Functional PHP Micro-Framework
Vance Lucas
 
Stackbox CMS: Next-Generation Content Management
Vance Lucas
 
Cross-Platform Mobile Development with Titanium
Vance Lucas
 
Alloy HMVC PHP Framework
Vance Lucas
 
Object Oriented Apologetics
Vance Lucas
 

Recently uploaded (20)

PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PPTX
Coupa-Overview _Assumptions presentation
annapureddyn
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PPTX
IoT Sensor Integration 2025 Powering Smart Tech and Industrial Automation.pptx
Rejig Digital
 
PDF
Software Development Company | KodekX
KodekX
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PDF
Beyond Automation: The Role of IoT Sensor Integration in Next-Gen Industries
Rejig Digital
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PPTX
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PDF
Architecture of the Future (09152021)
EdwardMeyman
 
PDF
Software Development Methodologies in 2025
KodekX
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Brief History of Internet - Early Days of Internet
sutharharshit158
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
Coupa-Overview _Assumptions presentation
annapureddyn
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
IoT Sensor Integration 2025 Powering Smart Tech and Industrial Automation.pptx
Rejig Digital
 
Software Development Company | KodekX
KodekX
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
Beyond Automation: The Role of IoT Sensor Integration in Next-Gen Industries
Rejig Digital
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Comunidade Salesforce São Paulo - Desmistificando o Omnistudio (Vlocity)
Francisco Vieira Júnior
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Architecture of the Future (09152021)
EdwardMeyman
 
Software Development Methodologies in 2025
KodekX
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Brief History of Internet - Early Days of Internet
sutharharshit158
 

PHP - Procedural To Object-Oriented

  • 1.  
  • 2. The Current Situation Object-Oriented Introduction Basics, concepts, terminology & examples Object-Oriented Benefits Code re-use, portability, structure, meaning, control, separation of responsibility, time, reduce dependencies and more
  • 3. Most scripts & tutorials all procedural or show bad understanding of OO PHP’s unique history Template language & PHP/FI 2.0 “ evolved” over time with OO features Good OO finally starting to emerge PHP5 released in 2004 Zend Framework Symfony Project
  • 4.  
  • 5. That was easy! Add “Object-Oriented PHP” to your resume!
  • 6. It’s much more than just syntax – It’s a mindset Object-Oriented programming gives meaning to your data Represents real-world objects when possible Where have we seen this before?
  • 7. Semantic markup Think: <blockquote> for quotes, not indentation <address> for addresses, not <p> or <div> <cite> instead of <i> for citations Goal is to for code to convey meaning
  • 8. Create meaning and structure Separate responsibilities Reduce/Isolate dependencies Create common public interfaces Clear, self-documenting code
  • 9. Code objects cannot always represent real-world objects Application flow Structure Delegation Separation of responsibilities How do we solve these problems? Design Patterns
  • 10. Model-View-Controller (MVC) Active Record Data Mapper Adapter Registry Factory Observer
  • 11. What OO programming is not – where many PHP projects go wrong
  • 12.  
  • 14. What is User? A finder/utility class? No clear definition or purpose “ bob” is a User 1 instance = 1 user Properties of a user Functions of a user
  • 15. The power of applying object-oriented design to your application
  • 16. Objects add automatic clarity Stick to standards and naming conventions camelCase Zend Coding Standards Function naming as verbose as possible getPostBySlug($slug) findPostsWithTag($tagName)
  • 17.  
  • 18.  
  • 19.  
  • 20. Parent > Child relationship between objects Child extends Parent Child inherits all parent methods Child can override parent methods when required Changes can be reflected across your entire application with relative ease
  • 21.  
  • 22. Hides actual implementation Reduces or isolates dependencies to lower levels Reduces or eliminates extensive future changes in code base
  • 23. Adding extra headers is a mess (CC, BCC) No built-in file attachment options Limited configuration options (Sendmail/SMTP) Very inefficient for large amounts of email
  • 24. Custom Email() object Clear, descriptive syntax Unlimited configuration options mail(), SMTP, database, external server, etc. File attachments can be easy with function
  • 25. Did you notice the dependencies?
  • 26. Remove the database dependencies by using a standard interface PDO provides one (bundled with PHP5) Use dependency injection to expose dependencies
  • 27. Pass connection into constructor and store it as a class property Replace mysql_* functions with standard functions from PDO using connection
  • 28. Database adapters are interchangeable
  • 29. Interchangeable code components Standard interface Single dependency Separate “engine” from implementation
  • 30. Different payment processors are a simple drop-in replacement
  • 31. Objects should serve a single purpose Separate code into manageable chunks MVC – Good example Model – Database View – Display Controller – Request/Flow Resist temptation of globals everywhere “ global $var”, $_SESSION, $_REQUEST, etc
  • 32.  
  • 33.  
  • 34. Building a Data Mapper with PHP5 and the Standard PHP Library Friday Oct. 10 @ 10:30am
  • 35. www.php.net/php5 Full official PHP5 feature documentation Communities Sitepoint – sitepoint.com PHPit – phpit.com PHP|Architect – phparch.com Zend Developer Zone - devzone.zend.com
  • 36. Vance Lucas, 23 Blog: www.vancelucas.com Email: [email_address] Making websites since age 12 Started learning PHP when PHP3 was new Oklahoma Baptist University – Shawee Bachelor of Business Administration Currently work at Back40 Design, Inc. www.back40design.com
  • 37.