Skip to content

laraveljobs-ir/php-solid

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SOLID in PHP

Table of Contents

  1. Introduction
  2. SOLID Principles
    1. Single-Responsibility Principle (SRP)
    2. Open-Closed Principle (OCP)
    3. Liskov Substitution Principle (LSP)
    4. Interface Segregation Principle (ISP)
    5. Dependency Inversion Principle (DIP)
  3. Project Structure
  4. Additional Resources

Introduction

In this project, you will learn about the SOLID principles, which are fundamental to object-oriented design. The project includes examples of each principle, demonstrating both correct and incorrect implementations in PHP.

SOLID Principles

Single-Responsibility Principle (SRP)

Single-responsibility Principle (SRP) states:

A class should have one and only one reason to change, meaning that a class should have only one job.

Open-Closed Principle

Open-closed Principle (OCP) states:

Objects or entities should be open for extension but closed for modification.

Liskov Substitution Principle

Liskov Substitution Principle states:

Let q(x) be a property provable about objects of x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T

Interface Segregation Principle

The interface segregation principle states:

A client should never be forced to implement an interface that it doesn’t use, or clients shouldn’t be forced to depend on methods they do not use.

Dependency Inversion Principle

Dependency inversion principle states:

Entities must depend on abstractions, not on concretions. It states that the high-level module must not depend on the low-level module, but they should depend on abstractions.

Project Structure

The project includes folders named after each SOLID principle. Inside each folder, there are two files: true.php and false.php. These files demonstrate the correct and incorrect implementations of each principle in PHP.

Additional Resources

To complete this project, I used the following resources:

Feel free to refer to these resources for a deeper understanding of SOLID principles.

About

This is an example for SOLID in php

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%