Object-Oriented PHP Part 4

In part 4 of this series on object-oriented PHP from KnpUniversity, we'll explore static methods, namespaces, exceptions, and traits. Getting a handle on these concepts will not only help you with PHP app development, but will also help you understand what's going on under-the-hood of Drupal 8.

Finally, we can really see all the cool OOP tools and concepts 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 and the other magic functions
  • Treat that $object[1] like an array (ArrayAccess)
  • Throwing and catching Exceptions
  • Traits! Horizontal code re-use
  • Composition Versus Inheritance: Dressing your classes for success

Other object-oriented PHP courses you might want to check out first:

You might also want to check out our guide, PHP Fundamentals for more PHP video tutorials.