title: Multiple namespaces under same module in ZF2
body: <p>I'm having trouble configuring multiple namespaces/classes under same module.
  For example, I have a module called "Account", in which I'd like to include all account related classes (companies: 'accounts', users: 'users', external api: 'api' etc.. ). Module structure looks like this..</p>
  
  <pre><code>        /Account
          - Module.php
          - /config
          - /view
          - /src
            - /Account
              - /Controller (AccountController.php)
              - /Form       (AccountForm.php)
              - /Model      (Account.php + AccountTable.php)
            - /User
              - /Controller (UserController.php)
              - /Form       (UserForm.php)
              - /Model      (User.php + UserTable.php)
            - /Api
              - Api.php     (simple class)
  </code></pre>
  
  <p>Being new to ZF2, I decided to keep things simple and stupid and Not to try implementing complex routing to Account module. So, in order to trigger indexAction for UserController, url should be /user (!)</p>
  
  <p>Here's the module class:</p>
  
  <pre><code>namespace Account;
  
  use Account\Model\AccountTable;
  use Account\Model\UserTable;
  
  class Module
  {
      public function getAutoloaderConfig()
      {
          return array(
                              'Zend\Loader\ClassMapAutoloader' =&gt; array(
                                                                                          __DIR__ . '/autoload_classmap.php',
                                                                                    ),
                              'Zend\Loader\StandardAutoloader' =&gt; array(
                                                                                          'namespaces' =&gt; array(
                                                                                                                          __NAMESPACE__ =&gt; __DIR__ . '/src/' . __NAMESPACE__,
                                                                                                                      ),
                                                                                 ),
          );
      }
  
      public function getServiceConfig()
      {
          return array(
                              'factories' =&gt; array(
                                                              'Account\Model\AccountTable'  =&gt;  function($sm) {
                                                                                                                                  $dbAdapter = $sm-&gt;get('Zend\Db\Adapter\Adapter');
                                                                                                                                  $table = new AccountTable($dbAdapter);
                                                                                                                                  return $table;
                                                                                                                              },
                                                              'Account\Model\UserTable'           =&gt;  function($sm) {
                                                                                                                                  $dbAdapter = $sm-&gt;get('Zend\Db\Adapter\Adapter');
                                                                                                                                  $table = new UserTable($dbAdapter);
                                                                                                                                  return $table;
                                                                                                                              },                                                              
                                                        ),
          );
      }    
  
      public function getConfig()
      {
          return include __DIR__ . '/config/module.config.php';
      }
  }
  </code></pre>
  
  <p>And the module.config file</p>
  
  <pre><code>return array(
      'controllers' =&gt; array(
          'invokables' =&gt; array(
              'Account\Controller\Account'    =&gt; 'Account\Controller\AccountController',
              'Account\Controller\User'           =&gt; 'Account\Controller\UserController',
          ),
      ),
  
      'router' =&gt; array(
          'routes' =&gt; array(
              'account' =&gt; array(
                  'type'    =&gt; 'segment',
                  'options' =&gt; array(
                      'route'      =&gt; '/account[/:action[/:accountId]]',
                      'constraints' =&gt; array(
                                                      'action'         =&gt; '[a-zA-Z][a-zA-Z0-9_-]*',
                                                      'accountId'      =&gt; '[0-9]+',
                                                  ),
                      'defaults' =&gt; array(
                          'controller' =&gt; 'Account\Controller\Account',
                          'action'     =&gt; 'index',
                      ),
                  ),
  /*
                  'may_terminate' =&gt; true,
                  'child_routes' =&gt; array(
                        'user' =&gt; array(
                              'type' =&gt; 'literal',
                              'options' =&gt; array(
                                  'route' =&gt; '/user[/:action[/:userId]]',
                                  'constraints' =&gt; array(
                                                      'action'         =&gt; '[a-zA-Z][a-zA-Z0-9_-]*',
                                                      'userId'         =&gt; '[0-9]+',
                                                  ),
                                  'defaults' =&gt; array(
                                          'controller' =&gt; 'Account\Controller\User',
                                          'action'     =&gt; 'index'
                                  )
                          )
                      )
                  ),
  */
              ),
              'user' =&gt; array(
                  'type'    =&gt; 'segment',
                  'options' =&gt; array(
                      'route'      =&gt; '/user[/:action[/:userId]]',
                      'constraints' =&gt; array(
                                                      'action'     =&gt; '[a-zA-Z][a-zA-Z0-9_-]*',
                                                      'userId'     =&gt; '[0-9]+',
                                                  ),
                      'defaults' =&gt; array(
                          'controller' =&gt; 'Account\Controller\User',
                          'action'     =&gt; 'index',
                      ),
                  ),
               )
  
  
          ),
      ),
  
      'view_manager' =&gt; array(
          'template_path_stack' =&gt; array(
              'account' =&gt; __DIR__ . '/../view',
              'user'    =&gt; __DIR__ . '/../view',
  
          ),
      ),
  );
  </code></pre>
  
  <p>But the error I'm getting is, "Class 'Account\Controller\UserController' not found". I am sure i've missed something. Any clue please?</p>
  
  <p>Thanks</p>