Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Browse all series

Object-Oriented Principles in PHP

Beginning developers are usually first introduced to procedural programming. But, before too long, they level up. Suddenly, an entirely different paradigm is introduced: object-oriented programming. Little do they know that they'll spend years researching and learning exactly what it means to work with objects and messages.

In this course, you'll be introduced to the core principles of object-oriented programming through the lens of PHP. We'll begin with the basic constructs and work our way up. The only prerequisite is an elementary understanding of the PHP language and syntax.

Progress

Series Info

Episodes
10
Run Time
2h 50m
Difficulty
Beginner
Last Updated
Dec 18, 2024
Version
Latest

Series Episodes

  1. Episodes (10)
    1. Classes

      Let's begin with an introduction to classes in PHP. I like to think of a class as a blueprint or template that defines the overall structure and behavior for an concept in your codebase.
    2. Objects

      If a class is the blueprint, then an object is an implementation of that blueprint. In this lesson, you'll learn how to create multiple instances of a class, work with constructors, and set internal state.
    3. DTOs, Types, and Static Analysis

      A data transfer object, or DTO, is a simple object that can carry data wherever it needs to go. In this lesson, you'll learn how to create a DTO, while using PHP's type system (and static analysis tools) to ensure that the data is valid.
    4. Dependencies, Coupling, and Interfaces

      Let's move on to dependencies! We'll discuss what they are, the concept of object coupling, and how we can leverage interfaces to allow for more flexible code.
    5. Inheritance and Abstract Classes

      Next up on our list is inheritance. It sounds fancy, but it's really not. Think of class inheritance in the same way that you would think of a family tree. Let's review a few practical examples to illustrate the general concept.
    6. Interfaces as Feature Filters

      Let's return to the topic of interfaces. You've already learned that interfaces can be used as a way to define a contract. However, there's also a second technique we can use: interfaces as feature blockades. I'll show you what I mean!
    7. Encapsulation and Visibility

      Encapsulation is yet another confusing word that mostly refers to hiding the internal state of an object. We may do so to improve the public API of a class, or to conceal private implementation details.
    8. From Getters and Setters to Property Hooks

      Let's take one lesson to focus on some new additions to the PHP language, itself. These additions can quite significantly alter how you organize your classes, and it's important that we review them. We'll examine the reason for getters and setters, and then move on to PHP 8.4 property hooks.
    9. Understanding Object Composition and Abstractions

      Object composition is quite simple. It refers to the concept that a class can contain pointers to other classes. This is incredibly powerful and allows us to build complex systems from simple parts.
    10. Object-Oriented Workshop

      Okay, let's put everything you've learned to the test. In this half hour workshop, we'll build a FileStorage interface with multiple implementations that can be swapped out, based upon the current environment.

Continue Learning