SOLID principles
SOLID encourages cohesive responsibilities and replaceable collaborators.
What it is
SOLID encourages cohesive responsibilities and replaceable collaborators.
When to use it
Use as questions to improve a design, not as a requirement to add abstractions.
Syntax
S: one coherent reason to change
O: extend real variability
L: preserve contract
I: narrow contracts
D: depend on stable boundariesExample
A payment gateway interface has a concrete benefit when switching providers or testing failures.
A repository wrapping every Eloquent method often adds little benefit in a small app.Common mistakes
Do not infer that every class needs an interface or that dependency injection requires elaborate layers.