AsfaqTamim / SOLID-Principles-in-PHP

SOLID Principles in PHP from Laracast

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SOLID Principles in PHP

This repository demonstrates the implementation of SOLID principles in PHP, providing clear examples for each principle. The SOLID principles are a set of five design principles that aim to make software design more understandable, flexible, and maintainable.

Table of Contents

  1. Introduction
  2. SOLID Principles
  3. Examples
  4. How to Use

Introduction

SOLID is an acronym that represents five design principles for writing maintainable and scalable software. These principles were introduced by Robert C. Martin and have become fundamental guidelines for object-oriented design. This repository serves as a practical guide to implementing SOLID principles in PHP with real-world examples.

SOLID Principles

Single Responsibility Principle (SRP)

The SRP states that a class should have only one reason to change. In other words, a class should have only one responsibility.

Open/Closed Principle (OCP)

The OCP suggests that a class should be open for extension but closed for modification. This means that you can add new functionality without altering existing code.

Liskov Substitution Principle (LSP)

The LSP states that objects of a superclass should be able to replace objects of a subclass without affecting the correctness of the program.

Interface Segregation Principle (ISP)

The ISP recommends that a class should not be forced to implement interfaces it does not use. It promotes the creation of smaller, more specific interfaces.

Dependency Inversion Principle (DIP)

The DIP emphasizes that high-level modules should not depend on low-level modules, but both should depend on abstractions. It also introduces the concept that abstractions should not depend on details, but details should depend on abstractions.

Examples

This repository includes practical examples demonstrating the application of each SOLID principle in PHP. Each example is contained within its own directory, providing clear illustrations of how to adhere to the principles.

How to Use

Clone the repository and explore each example to understand how SOLID principles can be implemented in PHP. Feel free to use the code as a reference or incorporate it into your own projects.

git clone https://github.com/mohasin-dev/solid-principles-in-php.git

About

SOLID Principles in PHP from Laracast


Languages

Language:PHP 100.0%