title: Zend Framework 2 View Manager - view file and requested action match
body: <p>I want to make automatic match view file - controller action.</p>
  
  <p>If <code>/Web/TestController/testAction</code> (module/controller/action) requested,</p>
  
  <p>ZF2 tries to load this view : <code>/web/test/test</code></p>
  
  <p>Then, I have to add this line to <code>template_map</code> to make It work :</p>
  
  <pre><code>'web/test/test'     =&gt; __DIR__ . '/../view/pages/test/test.phtml',
  </code></pre>
  
  <p>But I don't want to add this lines for all actions.</p>
  
  <p>Can it work like this :</p>
  
  <pre><code>'web/{ABC}/{XYZ}'     =&gt; __DIR__ . '/../view/pages/{ABC}/{XYZ}.phtml',
  </code></pre>
  
  <p>how do i make it so that it would automatically matches ?</p>
  
  <p><strong>module.config.php :</strong></p>
  
  <pre><code>return array(
      'router' =&gt; array(
          'routes' =&gt; array(
              'web' =&gt; array(
                  'type' =&gt; 'segment',
                  'options' =&gt; array(
                      'route' =&gt; '[/:action]',
                      'constraints' =&gt; array(),
                      'defaults' =&gt; array(
                          'controller' =&gt; 'Web\Controller\Test',
                      ),
                  )
              )
          )
      ),
  
  
      '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/test'       =&gt; __DIR__ . '/../view/layouts/test/test.phtml',
              'layout/default'    =&gt; __DIR__ . '/../view/layouts/default/default.phtml',
              'error/404'         =&gt; __DIR__ . '/../view/error/404.phtml',
              'error/index'       =&gt; __DIR__ . '/../view/error/index.phtml',
  
              'web/test/test'     =&gt; __DIR__ . '/../view/pages/test/test.phtml',
          ),
  
          'template_path_stack' =&gt; array(
              __DIR__ . '/../view',
          ),
  
          'layout'                    =&gt; 'layout/default'
      ),
  );
  </code></pre>