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
- The Wonder of Class Constants
- Static Methods
- Static vs. Non-Static Methods
- Namespaces and the use Statement
- 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!
Add new comment