title: Zend Framework Models and Doctrine 2 Entities
body: <p>I've recently integrated Doctrine 2 into my ZF app, using the method introduced here:</p>
  
  <p><a href="http://www.zendcasts.com/unit-testing-doctrine-2-entities/2011/02/" rel="nofollow">http://www.zendcasts.com/unit-testing-doctrine-2-entities/2011/02/</a></p>
  
  <p>I really like the way it works, however I'm confused a little bot on how this will affect the way I used to have my Models and Mappers.</p>
  
  <p>Let me explain the confusion by an example,</p>
  
  <p>Let's say we have User entities and Purchases as in the example given in ZendCast</p>
  
  <p>Right now I have these entities that Doctrine uses</p>
  
  <pre><code>/library/ZC/Entity
      User.php
      Purchase.php
  </code></pre>
  
  <p>Before I used to have</p>
  
  <pre><code>application/models/
      User.php (Application_Model_User)
      Purchase.php (Application_Model_Purchase)
  </code></pre>
  
  <p>In classes in application/models/ I used to write functions to act on entities, (Fat model thin controller principle), for example if I wanted to send an email to a user, I would create a method named sendMail in Application_Model_User.</p>
  
  <p>Now I'm not sure if I can add methods to files in /library/ZC/Entity, or if it's a good idea at all since Doctrine uses those files to manage database.</p>
  
  <p>I rather have a separate model file, I also used to have mapper files which worked on more than one Model, for example if I wanted to email all inactive users I would create a method emailInactiveUsers to Application_Model_UserMapper.</p>
  
  <p>How would I do that now?</p>
  
  <p>I also googled a little bit and I found this:</p>
  
  <p><a href="http://net.tutsplus.com/tutorials/php/zend-framework-from-scratch-models-and-integrating-doctrine-orm/" rel="nofollow">http://net.tutsplus.com/tutorials/php/zend-framework-from-scratch-models-and-integrating-doctrine-orm/</a></p>
  
  <p>It says </p>
  
  <blockquote>
    <p>A scaffolding tool, called Doctrine_Cli that creates models from the database very quickly</p>
  </blockquote>
  
  <p>However the command "generate-models-db" does not exist in my scripts/doctrine.php file. I'm not sure if this is something that Doctrine has stopped supporting in version 2 or what.</p>