DEV Community

Cover image for SOLID in PHP

SOLID in PHP

Emmanuel Valverde Ramos on September 25, 2020

What is SOLID? 🙄 It is a set of principles to have good software design practices compiled by Uncle Bob. Why should I use the...
Collapse
 
rescatado182 profile image
Diego Pinzón • • Edited

Hello Emmanuel, great article, really. I'm looking for a complete guide and with this I really find it and help me to learning these principles and how to implement on my work. I have a question, on LCP principle, and example two (invariants), do you explain: "The easiest way to avoid this would be to simply create the variable $weightOfPackageKg as a private constant" -> do you mean really to this var, or the class Shipping propiety $weightGreaterThan ?

Collapse
 
drobinsonsudo profile image
David Robinson •

Great explanation! The code samples (correct vs. incorrect) are great - they really helped illustrate the principles well. I am definitely bookmarking this. Thanks for putting so much work into this and sharing.

Collapse
 
evrtrabajo profile image
Emmanuel Valverde Ramos •

First of all thank you for the comment.

And on the other hand to tell you that thanks to comments like this I have the intention of continuing to post like this

Collapse
 
ahmardiy profile image
AhmardiY •

Wow, this is really great.

Collapse
 
dardsmind profile image
dardsmind •

This is the best explanation of SOLID Principles I found on the internet, I really like the drawing illustration as it explain well.

Collapse
 
m1tko profile image
Dimitar Kalenderov •

Very good explanation of the SOLID principles. Thank you!

Collapse
 
carlosrenatohr profile image
~👨🏻‍💻🇳🇮 •

In the middle of 2021-pandemic-chaos, this post came to refresh and enhance some pieces of my daily coding. I really appreciated the effort and time invested on this keystone summary as it's SOLID for coding in a good way.

Collapse
 
evrtrabajo profile image
Emmanuel Valverde Ramos •

I'm really happy that the post helped you

Collapse
 
xedinunknown profile image
Anton Ukhanev •

Pretty good practical explanation! Here I go into philosophical detail about why those principles are that way, how they relate to Separation of Concerns, and how they are coherent with the natural way things are.

dev.to/xedinunknown/separation-of-...

Collapse
 
evrtrabajo profile image
Emmanuel Valverde Ramos •

😍 Love it

Collapse
 
flagoon profile image
Pawel Kochanek •

I find this article by mistake, but it's awesome explanation of SOLID principles. By myself I understand only first two. The other three are nicely explained.

Collapse
 
evrtrabajo profile image
Emmanuel Valverde Ramos •

First of all, thank you for the feedback, I would like the post to have more visibility but you can see the algorithm of dev.to it's not helping

Collapse
 
squidbe profile image
squidbe • • Edited

Your article showed up in "Top 7 Posts From Last Week" (which is how I found it), so the algorithm doesn't seem to be hurting you. 🙂

Thread Thread
 
evrtrabajo profile image
Emmanuel Valverde Ramos •

Hahahah, Yes so it seems, but I have a small reader in which I read the dev.to via the API, and I haven't see my post on the api :D

Collapse
 
krmgns profile image
Kerem Güneş •

Cool article Emmanuel, thank you.

PS: PaymentFactory.initialize() can have PayableInterface return type, by the way.

Collapse
 
evrtrabajo profile image
Emmanuel Valverde Ramos •

Updated the signature of the method to public function initialize(string $type): PayableInterface Thank you for the feedback

Collapse
 
marcylina profile image
MarcyLina •

I love this explanation! I learn well through analogies so I found your illustrations to be very helpful 👍🏽

Collapse
 
chemaclass profile image
Jose M Valera Reales •

This post is great. Good job 👏

Collapse
 
evrtrabajo profile image
Emmanuel Valverde Ramos •

Thank you Chema :D

Collapse
 
daravahn profile image
Ralf Lopes •

Hey man great piece, wanna talk about in our conference? Submit here cfp-poa.thedevconf.com.br/

Regards

Collapse
 
burimbb profile image
burimbb •

Best thanks.

Collapse
 
jonathangreco profile image
Jonathan • • Edited

Learning by making mistakes is my mojo, the way you explained SOLID is the best to teach me how it's really working. Thank you

Collapse
 
evrtrabajo profile image
Emmanuel Valverde Ramos •

🙏 thanks really for saying that, I'm glad my article can help you

Collapse
 
yurieastwood profile image
Yuri Eastwood •

Nice article, topics were really well explained!

Collapse
 
evrtrabajo profile image
Emmanuel Valverde Ramos •

Thank you 🤩

Collapse
 
axsag profile image
Axsag •

Really useful and nicely explained !

Collapse
 
evrtrabajo profile image
Emmanuel Valverde Ramos •

Thank you!!!

Collapse
 
evrtrabajo profile image
Emmanuel Valverde Ramos •

In PHP mine too

Collapse
 
zer0uno profile image
zeroUno • • Edited

What's the sense of this statement "$user->authenticateUser($user)"?

Collapse
 
evrtrabajo profile image
Emmanuel Valverde Ramos •

What do you mean?

Collapse
 
zer0uno profile image
zeroUno •

Don't you see the double "$user"?

Thread Thread
 
evrtrabajo profile image
Emmanuel Valverde Ramos •

You are right Thank you

$loginService->authenticateUser($user);
Enter fullscreen mode Exit fullscreen mode
Collapse
 
lester220255 profile image
lester •
Collapse
 
evrtrabajo profile image
Emmanuel Valverde Ramos •

the examples of some patterns are from that website

Collapse
 
hbrawnak profile image
Md. Habibur Rahman •

Loved the way you explained.

Collapse
 
evrtrabajo profile image
Emmanuel Valverde Ramos •

Thank you