Object-oriented – OOP oriented PHP app source code samples and advice

object-orientedPHPsdlc

The day I have been dreading has arrived. I never felt OOP or good software design was important(I knew they were important, but I thought I could manage without them.). However having read otherwise almost everywhere on the interwebs, I started dreading the day when my client would ask me for new features in an existing app. The day has come and the pain is unbearable!

I have never coded my PHP websites "properly"(PHP is my primary language and the bulk of my work. I am learning Python (using web2py)) I take care that the website doesn't fall apart in a daily use scenario. I code pages like I was creating a list of static html files with bits of "magic code" in each of them(this bugs me a lot). How do I make the whole app more or less a single object? For eg. How do I design the object model for an invoicing app?

I use a lot of functions for doing any particular thing in the same fashion throughout the app(for eg. validation, generating ids, calculating taxes etc.).

I know the basics of OOP in general. Can anyone point me to source code samples of functional apps written in php? Or can someone provide pointers so I can recode my existing apps in a more modular way.

Best Answer

Check the Symfony framework and Doctrine ORM, those are the best coded and most well-architected PHP projects that I know of.

Early Software Architecture

Also, get familiar with design patterns, check FluffyCat's PHP Design Patterns page and check each pattern in wikipedia so you gain better insight to what they are for. In general, design patterns solutions to frequent problems (inherent to the language, and mostly object oriented), for example, the Composite design pattern helps you deal with nested categorization of stuff.

Good luck and welcome to early software architecture.

Related Topic