title: "Unable to resolve service "Album\Controller\AlbumController" to a factory; are you certain you provided it during configuration?" in Zend Framework 2
body: <p>I am getting an error in Zend Framework 2 tutorial project as,</p>
  
  <pre><code>Unable to resolve service "Album\Controller\AlbumController" to a factory; are you certain you provided it during configuration?
  </code></pre>
  
  <p>My Module.php as</p>
  
  <pre><code>namespace Album;
  
  use Zend\ModuleManager\Feature\ConfigProviderInterface;
  
  class Module implements ConfigProviderInterface
  {
  public function getConfig()
  {
      return include __DIR__ . '/../config/module.config.php';
  }
  
  public function getServiceConfig()
  {
      return [
          'factories' =&gt; [
              Model\AlbumTable::class =&gt; function($container) {
                  $tableGateway = $container-&gt;get(Model\AlbumTableGateway::class);
                  return new Model\AlbumTable($tableGateway);
              },
              Model\AlbumTableGateway::class =&gt; function ($container) {
                  $dbAdapter = $container-&gt;get(AdapterInterface::class);
                  $resultSetPrototype = new ResultSet();
                  $resultSetPrototype-&gt;setArrayObjectPrototype(new Model\Album());
                  return new TableGateway('album', $dbAdapter, null, $resultSetPrototype);
              },
          ],
      ];
  }
  
  public function getControllerConfig()
  {
      return [
          'factories' =&gt; [
              Controller\AlbumController::class =&gt; function($container) {
                  return new Controller\AlbumController(
                      $container-&gt;get(Model\AlbumTable::class)
                  );
              },
          ],
      ];
  }
  }
  </code></pre>
  
  <p>And my module.config.php is;</p>
  
  <pre><code>namespace Album;
  
  use Zend\Router\Http\Segment;
  
  //use Zend\ServiceManager\Factory\InvokableFactory;
  
  return [
  'controllers' =&gt; [
      'factories' =&gt; [
          Controller\AlbumController::class =&gt; InvokableFactory::class,
      ],
  ],
  
  'router' =&gt; [
      'routes' =&gt; [
          'album' =&gt; [
              'type'    =&gt; Segment::class,
              'options' =&gt; [
                  'route' =&gt; '/album[/:action[/:id]]',
                  'constraints' =&gt; [
                      'action' =&gt; '[a-zA-Z][a-zA-Z0-9_-]*',
                      'id'     =&gt; '[0-9]+',
                  ],
                  'defaults' =&gt; [
                      'controller' =&gt; Controller\AlbumController::class,
                      'action'     =&gt; 'index',
                  ],
              ],
          ],
      ],
  ],
  
  'view_manager' =&gt; [
      'template_path_stack' =&gt; [
          'album' =&gt; __DIR__ . '/../view',
      ],
  ],
  ];
  </code></pre>
  
  <p>I am very new in Zend Framework. Just can not figure out what I am doing wrong. Please mention if some more code is necessary.</p>