1

i have in module/config/module.config.php :

'router' => [
    'routes' => [
        'home-backend' => [
            'type' => Literal::class,
            'options' => [
                'route'    => '/backend',
                'defaults' => [
                    'controller' => Controller\IndexController::class,
                    'action'     => 'index',
                ],
            ],
        ],
        'backend' => [
            'type' => Segment::class,
            'options' => [
                'route'    => '/backend[/:controller[/:action]]',
                'defaults' => [
                    'controller' => Controller\IndexController::class,
                    'action'     => 'index',
                ],
            ],
            'may_terminate' => true,
            'child_routes' => [
                'wildcard' => [
                    'type' => 'Wildcard'
                ]
            ]
        ],  
    ],
],

when i call : http://mysite/backend/index/index error : Page not found. The requested controller could not be mapped to an existing controller class.

Controller: index (resolves to invalid controller class or alias: index)

what is problem??

2 Answers2

0

Seem you missed configuration for controller. Please add configuration for controller to module/config/module.config.php.

If you use factory, the configuration will be like this.

'controllers' => [
    'factories' => [
        Controller\IndexController::class => Controller\IndexControllerFactory::class,
    ]
],

If you don't use factory, the configuration will be like this

use Zend\ServiceManager\Factory\InvokableFactory;

return [
    'controllers' => [
        'factories' => [
            Controller\IndexController::class => InvokableFactory::class,
        ]
    ],
]
Dolly Aswin
  • 2,684
  • 1
  • 20
  • 23
0

Point that you should not use same route patten twice. Here I see /backend is used twice. Otherwise the route pattern for backend route is not well-formatted.

Hope you would understand the better way here!

unclexo
  • 3,691
  • 2
  • 18
  • 26