title: How can I Make a Successful Domain Object Factory in PHP
body: <p>I'm fiddling with an MVC framework, and I stumbled upon a problem I'm not sure how to solve.</p>
  
  <p>I want to make a <code>DomainObjectFactory</code> for the Model layer of my application, however, each Domain object would have a different set of arguments, for instance:</p>
  
  <ul>
  <li>Person - $id, $name, $age.</li>
  <li>Post - $id, $author, $title, $content, $comments</li>
  <li>Comment - $id, $author, $content</li>
  </ul>
  
  <p>And so on. How can I easily tell my factory what kinds of object do I require?</p>
  
  <p>I've came up with several options:</p>
  
  <ul>
  <li>Pass an array - I dislike this one, because you can't rely on the constructor's contract to tell what the object needs for his work.</li>
  <li>Make the <code>DomainObjectFactory</code> an interface, and make concrete classes - Problematic, because that's an awful lot of factories to make!</li>
  <li>Use Reflection - Service locator much? I don't know, it just seems that way to me.</li>
  </ul>
  
  <p>Is there a useful deign pattern I can employ here? Or some other clever solution?</p>