title: ZF2 Models shared between Modules
body: <p>I've just started setting up a new ZF2 application for a new project, based off the ZF2 skeleton, and am looking at their tutorial on <a href="http://framework.zend.com/manual/2.1/en/user-guide/database-and-models.html" rel="noreferrer">Models</a>.</p>
  <p>tl;dr: how should I share a Model between multiple different modules, by putting it somewhere in a higher level (outside /module)?</p>
  <p>We have several modules setup like so:</p>
  <pre><code>/
  /module/ModuleName
  /module/ModuleName/config
  /module/ModuleName/src
  /module/ModuleName/src/ModuleName
  </code></pre>
  <p>I was just about to setup a folder <code>/module/ModuleName/src/ModuleName/Model/TableName.php</code>, but then I realised: that table will need to be accessed in other Modules as well. So what should I do?</p>
  <p>Should I put the Models folder in <code>/module/Model</code> or will that be result in it being treated as a module i.e. site.com/model (based on our current config, it would).</p>
  <p>Should I copy and paste the models between places? Should I stick the models back in <code>/vendor/library/Company/Model</code> somewhere? Not quite sure if there's a best practice for this!</p>
  <p>Question 2: The tutorial also suggests to use ServiceManager to instantiate the database models to use the same instance. What if I have a module with 5 controllers, with each controller accessing completely separate tables (say 4 tables each)? It seems to me that it would redundantly initialise 16 tables on each page load (for the other controllers in that module). A single table initialisation adds 55ms to the pageload. Is there a way around this?? I'm not sure how I'd move the config to the controller's actions based on what the tutorial does to initialise the tablegateway?</p>