title: ZF3 zend-mvc generic route for many controllers in one module not working
body: <p>I'm in ZF3, using the zend-mvc-skeleton and trying to configure a generic route that will match as many URLs as possible as I want to be able to create new controllers (including action methods of course), and have them immediately available.</p>
  
  <p>The common approach described in the documentation is to write a route that matches the controller and action (same with ZF2).</p>
  
  <p>Here is my <code>module.config.php</code></p>
  
  <pre class="lang-php prettyprint-override"><code>namespace Application;
  
  use Zend\Router\Http\Literal;
  use Zend\Router\Http\Segment;
  use Zend\ServiceManager\Factory\InvokableFactory;
  
  return [
      'router' =&gt; [
          'routes' =&gt; [
              'home' =&gt; [
                  'type'    =&gt; Literal::class,
                  'options' =&gt; [
                      'route'    =&gt; '/',
                      'defaults' =&gt; [
                          'controller' =&gt; Controller\IndexController::class,
                          'action'     =&gt; 'index',
                      ],
                  ],
              ],
              'default' =&gt; [
                  'type' =&gt; Segment::class,
                  'options' =&gt; [
                      'route'    =&gt; '/application[/:controller[/:action]]',
                      'defaults' =&gt; [
                          'controller' =&gt; Controller\IndexController::class,
                          'action'     =&gt; 'index',
                      ],
                      'constraints' =&gt; [
                          'controller' =&gt; '[a-zA-Z][a-zA-Z0-9_-]*',
                          'action'     =&gt; '[a-zA-Z][a-zA-Z0-9_-]*',
                      ],
                  ],
              ],
          ],
      ],
      'controllers' =&gt; [/* ... */],
      'view_manager' =&gt; [/* ... */],
  ],
  </code></pre>
  
  <p>It works like a charm for <code>http://localhost/</code> and <code>http://localhost/application</code> calling the <code>indexAction()</code> function of the  <code>IndexController</code> class inside the <code>/module/Application/src/IndexController.php</code> file.</p>
  
  <p>However, it's not working when I try to get the <code>fooAction()</code> function in the same Controller (i.e. IndexController). It's not resolving correctly <code>http://localhost/application/foo</code>. and I get the following error:</p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>A 404 error occurred
  
  Page not found.
  
  The requested controller could not be mapped to an existing controller class.
  
  Controller:
  foo (resolves to invalid controller class or alias: foo)
  
  No Exception available
  </code></pre>
  
  <p>Same error if I try <code>http://localhost/bar/foo</code> to get the <code>fooAction()</code> in the <code>barController</code>.</p>
  
  <p>Do you have any idea of what's wrong with this? Any help will be appreciated. Many thanks.</p>