Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think the answer to this question depends on your needs, your time constraints and your overall approach to/style of software development.</p> <p>I have recently (A) made the decision to use Zend Framework on a small but complex web application that has a very tight deadline and (B) have spent a LOT of time investigating ORM solutions and different ZF application structures in general. The conclusion I have come to is that there isn't a one-size-fits-all solution and that you should feel free to get creative and build an application structure that <em>you</em> are happy with.</p> <p>If you have tight time constraints and the application isn't too large, then you could just create classes with names like <code>Application_Model_BlahService</code> and store them in the <code>application/models</code> directory and they will get picked up by default by the autoloader (assuming the autoloader has been bootstrapped correctly).</p> <p>But if your application is larger or if, for some other reason, you want to split classes out into more directories, you could create your own sub-directories under the application directory and use something like the code below (which would exist in your <code>application/Bootstrap.php</code>) to add those classes to the autoloader:</p> <pre><code>protected function _initResourceLoader() { $this-&gt;_resourceLoader-&gt;addResourceType( 'service', 'services', 'Service' ); $this-&gt;_resourceLoader-&gt;addResourceType( 'serviceplugin', 'services/plugins', 'Service_Plugin' ); } </code></pre> <p>You can then create classes like <code>Application_Service_Invoice</code>, which would reside in <code>application/services/Invoice.php</code> and <code>Application_Service_Plugin_TaxPlugin</code>, which would reside in <code>application/services/plugins/TaxPlugin.php</code>. (Note: the code above assumes you are using <code>Zend_Application</code>).</p> <p>You could, in theory, take this as far as you like and separate model classes from service classes from data access classes, etc etc etc. But again, it depends on the style of development that you prefer, the size of the team and, to some degree, what requirements your persistence layer imposes on you.</p> <p>One last quick thing: have a look in <code>Zend_Application_Module_Autoloader</code> for a list of resources that are added to the autoloader by default. (Should I have mentioned that I'm referring to ZF 1.8+ in this answer?)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload