title: ZF2 - get was unable to fetch or create an instance for getAlbumTable
body: <p>I used the getAlbumTable in the title since the problem I'm facing is based on the Zend Album Tutorial, might be easier for others having a similar problem to find. All I've done is rename  Album to "Champrallies".</p>
  
  <p>My error: </p>
  
  <pre><code>Zend\Mvc\Controller\PluginManager::get was unable to fetch or create an instance for getChampralliesTable
  </code></pre>
  
  <p>What I'm trying to do is execute a function from a second Model I've created. I can execute from the 'original' model no problem AlbumTable or in my case ChampionshipTable. I'm trying to get data from a second table, but within the same module. The second table is called "champ_rallies" and the Model files are Champrallies.php and ChampralliesTable.php.</p>
  
  <p>Changing this part in my controller</p>
  
  <pre><code>'champRallies' =&gt; $this-&gt;getChampralliesTable()-&gt;fetchAll(),
  </code></pre>
  
  <p>to</p>
  
  <pre><code>'champRallies' =&gt; $this-&gt;getChampionshipTable()-&gt;fetchAll(),
  </code></pre>
  
  <p>means the error message disappears. So my first thought is that there is something wrong with namespaces, or module.php. (Forgive me, I'm fairly new at all this)</p>
  
  <p>Module.php</p>
  
  <pre><code>&lt;?php
  namespace Championship;
  
  use Championship\Model\Championship;
  use Championship\Model\ChampionshipTable;
  use Championship\Model\Champrallies;
  use Championship\Model\ChampralliesTable;
  use Zend\Db\ResultSet\ResultSet;
  use Zend\Db\TableGateway\TableGateway;
  
  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 getConfig()
      {
          return include __DIR__ . '/config/module.config.php';
      }
  
      // Add this method:
      public function getServiceConfig()
      {
          return array(
              'factories' =&gt; array(
                  'Championship\Model\ChampionshipTable' =&gt;  function($sm) {
                      $tableGateway = $sm-&gt;get('ChampionshipTableGateway');
                      $table = new ChampionshipTable($tableGateway);
                      return $table;
                  },
                  'ChampionshipTableGateway' =&gt; function ($sm) {
                      $dbAdapter = $sm-&gt;get('Zend\Db\Adapter\Adapter');
                      $resultSetPrototype = new ResultSet();
                      $resultSetPrototype-&gt;setArrayObjectPrototype(new Championship());
                      return new TableGateway('championships', $dbAdapter, null, $resultSetPrototype);
                  },
                  'Championship\Model\ChampralliesTable' =&gt;  function($sm) {
                      $tableGateway = $sm-&gt;get('ChampralliesTableGateway');
                      $table = new ChampralliesTable($tableGateway);
                      return $table;
                  },
                  'ChampralliesTableGateway' =&gt; function ($sm) {
                      $dbAdapter = $sm-&gt;get('Zend\Db\Adapter\Adapter');
                      $resultSetPrototype = new ResultSet();
                      $resultSetPrototype-&gt;setArrayObjectPrototype(new Champrallies());
                      return new TableGateway('champ_rallies', $dbAdapter, null, $resultSetPrototype);
                  },
              ),
          );
      }
  }
  </code></pre>
  
  <p>My second thought is that perhaps I'm not declaring the right namespace, or something similar.</p>
  
  <p>ChampralliesTable.php</p>
  
  <pre><code>&lt;?php
  
  namespace Championship\Model;
  
  use Zend\Db\TableGateway\TableGateway;
  
  class ChampralliesTable
  </code></pre>
  
  <p>Champrallies.php</p>
  
  <pre><code>&lt;?php
  
  namespace Championship\Model;
  
  class Champrallies
  </code></pre>
  
  <p>I fear I'm overlooking something failure but I haven't found any similar posts through google or on here, any help is appreciated!</p>
  
  <p>edit: I had forgotten to add getChampralliesTable function to the controller itself,</p>
  
  <pre><code>public function getChampralliesTable()
  {
  This is Line 50 -&gt; if (!$this-&gt;champralliesTable) {
          $sm = $this-&gt;getServiceLocator();
          $this-&gt;champralliesTable = $sm-&gt;get('Championship\Model\ChampralliesTable');
      }
      return $this-&gt;champralliesTable;
  }
  </code></pre>
  
  <p>But now I'm getting this,</p>
  
  <pre><code>Notice: Undefined property: Championship\Controller\ChampionshipController::$champralliesTable in /usr/home/phil/git/rallystats/module/Championship/src/Championship/Controller/ChampionshipController.php on line 50
  </code></pre>