Release Day: Object-Oriented PHP Part 4

Image
Static Methods, Namespaces, Exceptions, Traits

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

New to object-oriented PHP? You might want to check these tutorials out first:

Check out our guide, PHP Fundamentals, for more PHP video tutorials.

Object-Oriented PHP Part 4

Add new comment

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <code class> <ul type> <ol start type> <li> <dl> <dt> <dd><h3 id> <p>
  • Lines and paragraphs break automatically.

About us

Drupalize.Me is the best resource for learning Drupal online. We have an extensive library covering multiple versions of Drupal and we are the most accurate and up-to-date Drupal resource. Learn more