title: Zend Framework 2 routing error: resolves to invalid controller class or alias
body: <p>I'm trying to learn Zend Framework 2 and I have their skeleton application up and running. In order to access it I visit <a href="http://localhost:8080/" rel="nofollow">http://localhost:8080/</a>. When visiting that link it displays their generic Zend page. What I want to be able to do is visit <a href="http://localhost:8080/application/test" rel="nofollow">http://localhost:8080/application/test</a> and have it bring me to a different page with a different layout.</p>
  
  <p>Here is the module.config.php</p>
  
  <pre><code>&lt;?php
  /**
   * Zend Framework (http://framework.zend.com/)
   *
   * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
   * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
   * @license   http://framework.zend.com/license/new-bsd New BSD License
   */
  
  return array(
      'router' =&gt; array(
          'routes' =&gt; array(
              'home' =&gt; array(
                  'type' =&gt; 'Zend\Mvc\Router\Http\Literal',
                  'options' =&gt; array(
                      'route'    =&gt; '/',
                      'defaults' =&gt; array(
                          'controller' =&gt; 'Application\Controller\Index',
                          'action'     =&gt; 'index',
                      ),
                  ),
              ),
              // The following is a route to simplify getting started creating
              // new controllers and actions without needing to create a new
              // module. Simply drop new controllers in, and you can access them
              // using the path /application/:controller/:action
              'application' =&gt; array(
                  'type'    =&gt; 'Literal',
                  'options' =&gt; array(
                      'route'    =&gt; '/application',
                      'defaults' =&gt; array(
                          '__NAMESPACE__' =&gt; 'Application\Controller',
                          'controller'    =&gt; 'Index',
                          'action'        =&gt; 'index',
                      ),
                  ),
                  'may_terminate' =&gt; true,
                  'child_routes' =&gt; array(
                      'default' =&gt; array(
                          'type'    =&gt; 'Segment',
                          'options' =&gt; array(
                              'route'    =&gt; '/[:controller[/:action]]',
                              'constraints' =&gt; array(
                                  'controller' =&gt; '[a-zA-Z][a-zA-Z0-9_-]*',
                                  'action'     =&gt; '[a-zA-Z][a-zA-Z0-9_-]*',
                              ),
                              'defaults' =&gt; array(
                              ),
                          ),
                      ),
                  ),
              ),
          )
      ),
      'service_manager' =&gt; array(
          'abstract_factories' =&gt; array(
              'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
              'Zend\Log\LoggerAbstractServiceFactory',
          ),
          'aliases' =&gt; array(
              'translator' =&gt; 'MvcTranslator',
          ),
      ),
      'translator' =&gt; array(
          'locale' =&gt; 'en_US',
          'translation_file_patterns' =&gt; array(
              array(
                  'type'     =&gt; 'gettext',
                  'base_dir' =&gt; __DIR__ . '/../language',
                  'pattern'  =&gt; '%s.mo',
              ),
          ),
      ),
      'controllers' =&gt; array(
          'invokables' =&gt; array(
              'Application\Controller\Index' =&gt; 'Application\Controller\IndexController'
          ),
      ),
      'view_manager' =&gt; array(
          'display_not_found_reason' =&gt; true,
          'display_exceptions'       =&gt; true,
          'doctype'                  =&gt; 'HTML5',
          'not_found_template'       =&gt; 'error/404',
          'exception_template'       =&gt; 'error/index',
          'template_map' =&gt; array(
              'layout/layout'           =&gt; __DIR__ . '/../view/layout/layout.phtml',
              'application/index/index' =&gt; __DIR__ . '/../view/application/index/index.phtml',
              'error/404'               =&gt; __DIR__ . '/../view/error/404.phtml',
              'error/index'             =&gt; __DIR__ . '/../view/error/index.phtml',
          ),
          'template_path_stack' =&gt; array(
              __DIR__ . '/../view',
          ),
      ),
      // Placeholder for console routes
      'console' =&gt; array(
          'router' =&gt; array(
              'routes' =&gt; array(
              ),
          ),
      ),
  );
  </code></pre>
  
  <p>In order to make it work for me this is what I tried:</p>
  
  <p>First I created a controller named TestController in Application/src/Application/Controller/.</p>
  
  <p>Next I added 'application/test/index' => <strong>DIR</strong> . '/../view/application/test/index.phtml' to the template_map array in view_manager.</p>
  
  <p>I also added 'Application\Controller\Test' => 'Application\Controller\TestController' to the controllers array.</p>
  
  <p>When I visit <a href="http://localhost:8080/application/test" rel="nofollow">http://localhost:8080/application/test</a> I get the error:
  test(resolves to invalid controller class or alias: test)</p>
  
  <p>I'm obviously doing something wrong but tbh the documentation on Zend is not newb friendly at all and it's becoming very frustrating. Could someone point me in the correct direction? There's just so much configuration that I'm sure I'm missing something small. Thanks!</p>