title: How to use a class from another module in a Zend Front Controller Plugin?
body: <p>We are currently reorganising our application (based on Zend framework 1.11) into a modular structure and are running in to the problem that we need to be able to use resources within a module before the autoloader for that module has been registered.</p>
  
  <p>For example, we have a front controller plugin to check the user's login status..</p>
  
  <pre><code>class Application_Plugin_LoginCheck extends Zend_Controller_Plugin_Abstract {
  
      public function preDispatch(Zend_Controller_Request_Abstract $request) {
  
          // ACL-lookup code which ultimately retrieves Othermodule_Model_User 
          // from session
          // Othermodule_Model_User is not defined
      }
  }
  </code></pre>
  
  <p>We need <code>Othermodule_Model_User</code> to be available at this point but it seems that the autoloader for <code>Othermodule</code> will not be registered until the bootstrap sequence. </p>
  
  <p>Similarly, this same issue prevents us using classes form any another module in any given module's bootstrap class.</p>
  
  <p>What is the proper way to achieve this kind of setup in a Zend Framework application?</p>
  
  <p>Bootstrapping is being done using Zend's application bootstrap and module bootstrap classes. I've included an example below - I don't think we're doing anything unusual.</p>
  
  <p>Application bootstrap:</p>
  
  <pre><code>class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
  
      protected function _initDb() {...}
  
      protected function _initConfig() {...}
  
      protected function _initLog() {...}
  
      protected function _initMvcStaticRoutes() {...}
  
      protected function _initRestRoute() {...}
  
      protected function _initTranslate() {...}
  
      public function _initActionHelpers() {...}
  
      public function _initViewHelpers() {...} 
  }
  </code></pre>
  
  <p>Module bootstrap:</p>
  
  <pre><code>class Account_Bootstrap extends Zend_Application_Module_Bootstrap { 
      protected function _initTranslate() {
          ...
      }
  }
  </code></pre>
  
  <p>The plugin is registered in the application config </p>
  
  <pre><code>resources.frontController.plugins.logincheck.class = "Application_Plugin_LoginCheck"
  </code></pre>