0

I am new to Zend. I have set up local dev at zend.local I am creating a new module say Csv, when I go to URL like zend.local/csv, it gives me the following error enter image description here

My module.config.php is below:

<?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',
        ),
    ),
);
tereško
  • 58,060
  • 25
  • 98
  • 150
baig772
  • 3,404
  • 11
  • 48
  • 93

2 Answers2

1

you have provided the wrong controller name :

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

it should be

             'defaults' => array(
                 'controller' => 'Csv\Controller\Csv',
                 'action'     => 'index',
             ),

according to your config

'controllers' => array(
    'invokables' => array(
        'Csv\Controller\Csv' => 'Csv\Controller\IndexController',
    ),
),
Exlord
  • 5,009
  • 4
  • 31
  • 51
-1

You require the may_terminate option to ensure the router can regard csv as a route that it can terminate at.

'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',
        ),
    ),
    'may_terminate' => true // added
),
Community
  • 1
  • 1
AlexP
  • 9,906
  • 1
  • 24
  • 43