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
DOCX
Object oriented programming tutorial
PPTX
Principles and advantages of oop ppt
PPTX
Characteristics of OOPS
PPTX
Object Oriented Programming Principles
PPTX
Characteristics of oop
PPTX
Introduction to Object Oriented Programming
Object oriented programming
Object oriented programming tutorial
Principles and advantages of oop ppt
Characteristics of OOPS
Object Oriented Programming Principles
Characteristics of oop
Introduction to Object Oriented Programming

What's hot (20)

PDF
Object-oriented programming (OOP) with Complete understanding modules
PDF
Concepts of OOPs
PPT
Oop Presentation
PPTX
Object oriented programming
PPT
OOP programming
PPTX
Oop ppt
PPTX
Object Oriented Programming in Java _lecture 1
PDF
Introduction to object oriented programming
PPTX
Object Oriented Concept
PDF
PPT
Oops
PPT
2 Object Oriented Programming
PPTX
principle of oop’s in cpp
PPTX
Introduction to Object Oriented Programming
PPTX
01 introduction to oop and java
PPTX
OOP - Benefits and advantages of OOP
PPTX
Oo ps concepts in c++
PPTX
Object-Oriented concepts.pptx
Object-oriented programming (OOP) with Complete understanding modules
Concepts of OOPs
Oop Presentation
Object oriented programming
OOP programming
Oop ppt
Object Oriented Programming in Java _lecture 1
Introduction to object oriented programming
Object Oriented Concept
Oops
2 Object Oriented Programming
principle of oop’s in cpp
Introduction to Object Oriented Programming
01 introduction to oop and java
OOP - Benefits and advantages of OOP
Oo ps concepts in c++
Object-Oriented concepts.pptx
Ad

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

PDF
A Gentle Introduction To Object Oriented Php
ZIP
Object Oriented PHP5
PDF
Introduction into PHP5 (Jeroen van Sluijs)
PDF
Introduction to PHP (SDPHP)
PPTX
Introduction to PHP and MySql basics.pptx
PDF
OOP in PHP
ODP
Best practices tekx
PPTX
OOP Day 2
PPT
Building Data Mapper PHP5
PPT
PHP- Introduction to Object Oriented PHP
PPT
Introduction to PHP - SDPHP
DOC
Oss questions
PDF
Professional PHP: an open-source alternative for enterprise development [Kort...
PPTX
Object oriented programming in php 5
PPTX
Object oriented programming in php 5
PPT
Phpwebdevelping
PDF
Demystifying Object-Oriented Programming - PHP[tek] 2017
PDF
6 Months Industrial Project Training in PHP Delhi/NCR
PPT
PHP 5 Boot Camp
PDF
Object Oriented Programming with Laravel - Session 1
A Gentle Introduction To Object Oriented Php
Object Oriented PHP5
Introduction into PHP5 (Jeroen van Sluijs)
Introduction to PHP (SDPHP)
Introduction to PHP and MySql basics.pptx
OOP in PHP
Best practices tekx
OOP Day 2
Building Data Mapper PHP5
PHP- Introduction to Object Oriented PHP
Introduction to PHP - SDPHP
Oss questions
Professional PHP: an open-source alternative for enterprise development [Kort...
Object oriented programming in php 5
Object oriented programming in php 5
Phpwebdevelping
Demystifying Object-Oriented Programming - PHP[tek] 2017
6 Months Industrial Project Training in PHP Delhi/NCR
PHP 5 Boot Camp
Object Oriented Programming with Laravel - Session 1
Ad

More from Vance Lucas (7)

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

Recently uploaded (20)

PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Empathic Computing: Creating Shared Understanding
PDF
Electronic commerce courselecture one. Pdf
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPT
Teaching material agriculture food technology
PDF
Unlocking AI with Model Context Protocol (MCP)
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Approach and Philosophy of On baking technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Encapsulation_ Review paper, used for researhc scholars
NewMind AI Monthly Chronicles - July 2025
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Mobile App Security Testing_ A Comprehensive Guide.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Machine learning based COVID-19 study performance prediction
Empathic Computing: Creating Shared Understanding
Electronic commerce courselecture one. Pdf
MYSQL Presentation for SQL database connectivity
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Teaching material agriculture food technology
Unlocking AI with Model Context Protocol (MCP)
“AI and Expert System Decision Support & Business Intelligence Systems”
Building Integrated photovoltaic BIPV_UPV.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Approach and Philosophy of On baking technology

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.