SOLID is the mnemonic acronym that represents 5 design principles that aim to make software designs more understandable, flexible, and sustainable.
In this repository, you will find a folder under src/
for each principle and each principle has two folders: one for the stable version and one for the unstable version.
The Stable
folder contains one of the possible ways to apply the principle to the given use case. The Unstable
folder contains an example of how the same use case would be without applying the principle.
Install the dependencies:
composer install --prefer-dist
Run the classes by specifying the principle name (either in snake_case or kebab-case) and optionally the stable/unstable flag.
composer class [principle-name] [stable|unstable]
Example:
composer class single-responsibility stable
Each entity (module, class, or function) should have a single responsibility for a part of a feature in a system, and this responsibility should be encapsulated. In other words, each module should be responsible for a single thing or have only one reason to change.
Each entity should be closed for modification but open for extension.
If B is a subtype of A, then objects of type A should be exchangeable by objects of type B without affecting the desired result.
A client should not be forced to depend on methods it does not use.
High-level modules should not import anything from low-level modules. Both should depend on abstractions.
Agile Software Development: Principles, Patterns, and Practices: https://www.amazon.com/Software-Development-Principles-Patterns-Practices/dp/0135974445
Clean Architecture: A Craftsman's Guide to Software Structure and Design: https://www.amazon.com/Clean-Architecture-Craftsmans-Software-Structure/dp/0134494164
This is an open-source project licensed under the MIT license.