Home » Php » unit testing – PHP project with excellent OOP design for studying purposes

unit testing – PHP project with excellent OOP design for studying purposes

Posted by: admin July 12, 2020 Leave a comment


I’ve recently became interested in proper OOP design in web applications. I think I understand most of the principles and design patterns but sometimes I have problem with putting them into practice.

I use MVC and I think I am able to design controllers and views in OOP way. The problem I face is with models. I’m particularly obsessed with dependency injection and inversion of control in general. It works nice in small examples but I have trouble to design complex multi layered models – I’m thinking about various ways to inject dependencies into lower layers etc.

So I decided to look for some projects made by more experienced OOP programmers which I could study. I’m looking for PHP web application, preferably made with MVC architectural pattern. Also I don’t mind if it has anemic model (which is usually considered to be antipattern but in heavy data based applications I’m often forced to use anemic models).

Thanks a lot.

EDIT: I’m not looking for a framework but for a complete application. Frameworks usually have not a lot of to do with model architecture.

How to&Answers:

Magento Commerce has complex multi layered models (www.magentocommerce.com) which you may pick up a trick or two from.

But my (personal) experience with Magento was frustrating: I was hacking with it around version 0.8-1.1 and it appeared over engineered and poorly documented. Trying to figure out how it actually worked was complex: you’d end up with tons files open in your editor, most of them called Abstract.php. Hopefully things have improved a long way since then.


Code igniter is php4, i don’t recommend it too much. PHP OOP has changed since then. A better idea would be kohana

I learned a lot by checking out Konstrukt. The creator is semi active on SO too =)


I recommend you take a look at Symfony 2.

It is probably the best designed PHP project you’ll find. It’s SOLID, DRY and uses patterns where applicable.


What exactly is the problem you are facing with “Models”? You talk about Dependency Injection, but that really has nothing to do with the concept of a “Model” in the MVC context. If you are looking for examples of how to manage and pass dependencies down object hierarchies, you might want to take a look at Symfony 2.0’s Dependency Injection Container implementation.


I highly recommend the CodeIgniter from scratch series on Nettuts+.


EDIT: @Galen

This is not correct. CodeIgniter supports PHP 5.3.0 since version 1.7.2.


If you’re looking for “excellent OOP design” you’re probably looking into the wrong corner. PHP is not very strong at it’s OOP patterns. If your study and situation permits I recommend you looking into a Java project instead.


The CodeIgniter framework comes to mind as a decent study source