Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

SymfonyCasts

OOP (course 4): Static methods, Namespaces, Exceptions & Traits! Woh!

via SymfonyCasts

Overview

Finally, we can really unload and see all the cool OOP stuff that we haven't covered yet. These are the last missing pieces that are standing between you and understanding any OO code you meet.

  • Static methods
  • Class constants
  • Namespaces
  • Autoloading (RIP require statements)
  • __toString & the other magic functions
  • Treat that $object[1] like an array (ArrayAccess)
  • Throwing and catching a baseball Exceptions
  • Traits! Horizontal code re-use
  • Composition Versus Inheritance: Dressing your classes for success

Finally, you're going to start to see some serious pay-off from these new, crazy OO skills you've got. In this tutorial, OO is here to impress us. Dig in.

Syllabus

  • The Wonder of Class Constants
  • Static Methods
  • Static or Non-Static Methods?
  • Namespaces make Class Names Longer
  • Autoloading Awesomeness
  • More Fun with use Statements
  • Namespaces and Core PHP Classes
  • Composer Autoloading
  • Throwing an Exception (and a Party)
  • Different Exception Classes
  • Magic Methods: __toString() __get, __set()
  • ArrayAccess: Treat your Object like an Array
  • IteratorAggregate: Loop over an Object!?
  • Traits: "Horizontal" Reuse
  • Object Composition FTW!

Taught by

Ryan Weaver and Leanna Pelham

Reviews

Start your review of OOP (course 4): Static methods, Namespaces, Exceptions & Traits! Woh!

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.