Php ZF2控制器映射问题

Php ZF2控制器映射问题,php,zend-framework2,zend-framework-modules,zend-framework-routing,Php,Zend Framework2,Zend Framework Modules,Zend Framework Routing,我是新来的Zend。 我已在zend.local 我正在创建一个新模块,比如说Csv,当我转到像zend.local/Csv这样的URL时,它会给我以下错误 我的module.config.php如下: <?php return array( 'controllers' => array( 'invokables' => array( 'Csv\Controller\Csv' => 'Csv\Controller\Inde

我是新来的Zend。 我已在
zend.local
我正在创建一个新模块,比如说Csv,当我转到像zend.local/Csv这样的URL时,它会给我以下错误

我的
module.config.php
如下:

<?php
return array(
    'controllers' => array(
        'invokables' => array(
            'Csv\Controller\Csv' => 'Csv\Controller\IndexController',
        ),
    ),
     'router' => array(
         'routes' => array(
             'csv' => array(
                 'type'    => 'segment',
                 'options' => array(
                     'route'    => '/csv[/][:action][/:id]',
                     'constraints' => array(
                         'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                         'id'     => '[0-9]+',
                     ),
                     'defaults' => array(
                         'controller' => 'Csv\Controller\IndexController',
                         'action'     => 'index',
                     ),
                 ),
             ),
         ),
     ),

    'view_manager' => array(
        'template_path_stack' => array(
            'csv' => __DIR__ . '/../view',
        ),
    ),
);
您需要该选项以确保路由器可以将
csv
视为其可以终止的路由


您提供了错误的控制器名称:

             'defaults' => array(
                 'controller' => 'Csv\Controller\IndexController',
                 'action'     => 'index',
             ),
应该是

             'defaults' => array(
                 'controller' => 'Csv\Controller\Csv',
                 'action'     => 'index',
             ),
根据你的配置

'controllers' => array(
    'invokables' => array(
        'Csv\Controller\Csv' => 'Csv\Controller\IndexController',
    ),
),

只有在有子路线时才需要终止
'controllers' => array(
    'invokables' => array(
        'Csv\Controller\Csv' => 'Csv\Controller\IndexController',
    ),
),