PHP OOP Fundamentals Articles - Feedback Request

Hi guys,

I’ve recently been inspired to write some blog posts for the first time in nearly two years. This was prompted by a discussion in the office when one member of the team wanted to show another an example that would simplify his code. I felt that we could make it even better, and the team agreed. So I wrote it up.

That became my Don’t Inject Dependency Injection Containers post, which I had some really good feedback about.

I decided to try do write a few others, including talking a little about Encapsulation and Polymorphism. I don’t feel that these posts were as successful as the first, however. I’d be very interested in any constructive feedback that anyone here has though.

You can find the whole series (so far) here:

The DI Container Injection post is here:

1 Like

Great articles. I’ve read all of them. Love the “Don’t Inject DI containers” one.

In your “Polymorphism in PHP” article, you could also do a full circle back and enforce the learnings you taught with the encapsulation article by noting at the end that reworking the internals of the image classes would have absolutely no effect on the client code. (A Carburetor vs. ECU kind of thing. Great analogy with the car btw.) Your articles have made the concept “Code to an interface, not an implementation” much clearer to me and how that fits with polymorphism and understanding how to get a class to be polymorphic is one of the more important parts of mastering OOP to me. :smile:


1 Like

Thanks @s_molinari. That DI container one does get a lot of good feedback and I put that down to the fact that it came out of a really good conversation that we had in the office so is not my own work :smile:

Interesting point about the Polymorphism in PHP article. I do feel very strongly that polymorphism and encapsulation go hand in hand, so it certainly wouldn’t hurt to reiterate the point on encapsulation though, and to refer the reader back to the encapsulation article if they haven’t already read it.

Ultimately, the point of these articles is my attempt to help make understanding these concepts easier. I found it incredibly difficult to find articles that didn’t assume that I was either an expert already or a complete novice when I was learning so I was aiming for some kind of middle ground. Hopefully I hit that. If it’s helped one person understand the concepts better though then as far as I’m concerned, that’s mission accomplished. so thank you.

There is a missing article that I must write though, and that’s about favouring composition over inheritance, but understanding that both have their place. That should be a fun one :smile:

I like your articles, it was very good to read. Although I wont call them OOP ‘fundamentals’, since the four articles I found in your first link are actually aimed at more advanced OOP programmers, at least intermediate levels, as you need to have at least some experience of writing OOP code to have a good appreciation of these topics. Many coders are already in the market writing programs without realizing some of the principles, such as ‘Do not inject DI Container’. But I very like them, I hope you keep up posting more insightful articles like this.



Hi @Hall_of_Famer, thanks for the feedback.

I guess I see polymorphism, encapsulation and composition as fundamental concepts and that’s where my titles have come from. The composition article will follow, by the way, so hopefully that’ll keep you and @s_molinari happy at least :smile:

Thanks again

You are very welcome, I like your articles, and I feel it will help coders write better programs, than most OOP articles you find on google which only explains the syntax of OOP. Its better to teach them when to use it and why to use it, than just how to use it. I actually found one point in your ‘lets talk about encapsulation’ article very intriguing. You talked about validation logic there, and put the validation logic in setter methods, I think I will make a new post about validation logic so as not to digress too much from here. Again I like your articles, its very good for people already understanding the very basics of OOP, to advance to next level.

I should ask @swader if there’s any room on the writing staff :slight_smile:

1 Like

I would say that sitepoint should hire you to write some articles about PHP and OOP, if you keep doing this.

1 Like

There’s room and then some : )

See here and get in touch!


Consider it done. Thanks Bruno

It’s not OOP fundamentals, but I’ve added another article about the various MySQL extensions available in PHP. I intend on writing up some migration advice for people who want to move to PDO but are afraid of doing so :smile:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.