DEV Community


OOP practice with a standard project in PHP.

Kabir Hossain
I am a php developer. I want to learn a deep more.
・1 min read

I know OOP in PHP. But I do not know how to use them as a master of OOP. So I want to learn OOP deeply with a project. Is there any standard video of a project using OOP in PHP ? I want to learn standard coding also.

cover image

Discussion (7)

whoisryosuke profile image
Ryosuke • Edited

This video was my intro to SOLID OOP and all the principles behind it:

If you're more into text, this tutorial did a good job of explaining stuff as well, albeit a bit old.

I highly recommend doing a small intro to OOP (tutorial or video) to roughly understand the fundamental structure (using classes, how to reference $this, dependency injection). Then once you've got that under your belt, try working with an ultra-simple OOP project. I picked up this one, and it helped break down the responsibilities of all the classes + methods.

I'd also recommend learning a framework like Laravel. It's primarily with OOP, and although it does some more complex stuff (interfaces, traits, etc) -- it'll force you to work within the paradigm. Check out the PHP section of Laracasts for guides to PHP basics, Jeffrey Way does a great job of walking you through it.

Don't worry if you get lost with all the "Liskov" principles or whatever. At the end of the day, OOP is class-orientated coding (as opposed to procedural or functional). If you're using classes, your 80% of the way there. The rest will come with practice. It's when you refactor your code, or reflect on it, that you'll start to apply the principles. You'll notice you repeating methods across multiple classes (leading to interfaces, traits, or extended classes), or you'll have issues with classes/methods becoming too complex (inside out principle). As you code OOP more you'll grasp it more.

kabircse profile image
Kabir Hossain Author • Edited

Thanks for your comment.
I know the basics of design pattern and design principle. But I can not apply those in my own code. I will try your video. It would be better, If I got a real life video of a project applying those. I am searching it.

cotcotcoder profile image

Hi Kabir,

I stopped PHP so I can only recommand:
(Chapter 3 talks about standard coding.)

Best way to learn OOP is, in my way, to look at project source, maybe Laravel is a good start. And you can learn about DesignPattern with Github/Gist exemples (like this one:

cjbrooks12 profile image
Casey Brooks

That was my first thought as well, studying/working with Laravel. The way you work with it enforces good OOP practices, and the Laravel codebase itself has really good, clean OOP code under-the-hood, and so can help you understand good practices.

kabircse profile image
Kabir Hossain Author

Thanks for your comment. I am working on laravel without using OOP sense. Is there any resource to understand the laravel core easily ?

Thread Thread
cjbrooks12 profile image
Casey Brooks

None that I'm aware of. I've just found myself frequently digging into the source to understand it better as I worked with it

corsari profile image

I would like to suggest this read