15

This question is a continuation of my previous question here zend models architecture (big thanks to Bill Karwin). I've made some reading including this article

and this question

Now I understand, what domain driven design is. But examples are still very simple and poor. They are based on one table and one model. Now, my question is: do they use Domain Model Design in real-world PHP projects?

I've been looking for some good documentation about this, but I haven't found anything good enough, that explains how to manage several tables and transfer them to Domain Objects. As long as I know, there is Hibernate library, that has this features in Java, but what should I use in PHP (Zend Framework)?

Community
  • 1
  • 1
mik
  • 1,575
  • 6
  • 22
  • 33
  • DDD is definitely used with PHP in the real world. I'm at the tail end of a medium sized project using it at the moment. I agree that there are a lack of examples out there, generally I recommend looking at some java and c# code (which as a PHP developer you'll be able to understand). In general you'll find few examples of DDD applications - and the reason is obvious, in DDD the model is context specific, sample apps in DDD are time consuming to write, and there's little prospect of re-using the code. – thelastshadow Feb 21 '14 at 13:57

2 Answers2

18

There is a newsgroup formed by Matthias Verraes about doing DDD in PHP, mainly with Sf2.

Somewhat older is a series of articles by Federico Cargnelutti on how to do DDD with PHP and in parts with ZF that might be of interest to you:

Regarding ZF, there has been a proposal for Zend_Entity and Zend_DataMapper for some time, but development on those has been terminated in favor of integrating ZF with Doctrine. Doctrine is also the closest thing to Hibernate in PHP.

When googling for DDD with PHP, there will be a few additional resources, but nothing as comprehensive as the resources available at the official DDD site with code for the App described in Eric Evan's DDD book.

Gordon
  • 312,688
  • 75
  • 539
  • 559
  • Just for future references, it seems that this development method is gaining popularity in the PHP community. Mathias Verraes (if you're interested in DDD in PHP you should follow him) started a [DDD PHP mailing group](https://groups.google.com/forum/#!forum/dddinphp). Also some symfony folks have published some examples of a (small) DDD applications, see [1](https://github.com/igorw/doucheswag) and [2](https://github.com/MarcelloDuarte/hexagonal-symfony) – mTorres May 28 '14 at 12:33
2

Have a look at my project at GitHub. It tried to follow the principles of DDD, SOLID and OOP. PHP and DDD. There is no ORM inside but a hand-made Data Access Layer. Domain entities exchange messages. Presentation Layer gets a special kind of objects. You will find a lot of factories. They are intended to simplify unit testing and maintenace. I hope some techniques can be of interest for you.