What is OOP
Object-Oriented Programming in PHP is about organizing code around “things” instead of just steps.
In procedural PHP, we write functions that execute sequentially. In OOP, we define blueprints (classes) and create instances of those blueprints (objects). Each object represents a specific instance with its own data.
A class is a template. An object is a concrete instance of that template.
For example, instead of writing separate functions to manage memberships, transactions, and subscriptions, we can create classes like Membership, Transaction, or Subscription. Each object created from those classes represents a real entity in the system.
OOP encourages structure, reuse, and clarity. Instead of repeating logic across multiple functions, we group related behavior inside classes. This aligns with the DRY principle – shared logic lives in one place.
At this stage, the only thing that matters is understanding the mental model:
Class = blueprint
Object = instance of that blueprint
Objects inherit structure (properties and methods) from the class, but each object can hold different values.