1. Single Responsibility Principle (SRP)
Every class should have one, and only one, reason to change. Separate data persistence, email notification, and report generation into decoupled classes.
2. Open / Closed Principle (OCP)
Classes should be open for extension, but closed for modification. Leverage PHP interfaces to define contracts that allow swapping notification providers (e.g. Mailgun, SendGrid) without modifying the consumer code.
3. Liskov Substitution Principle (LSP)
Subclasses must be substitutable for their base types without altering system correctness. Avoid overriding methods with incompatible parameter types or unexpected exceptions.
4. Interface Segregation Principle (ISP)
Clients should not be forced to depend upon interfaces that they do not use. Split fat interfaces into fine-grained role interfaces.
5. Dependency Inversion Principle (DIP)
High-level modules should not depend upon low-level modules; both should depend on abstractions. Utilize Laravel or PHP-DI service containers to inject abstractions.
6. Real-World Application
Apply these patterns when refactoring a monolithic e-commerce module: extract PaymentProcessor, InvoiceGenerator, and OrderDispatcher into dedicated service classes, each satisfying one principle.