请求的控制器无法映射到现有的控制器类。 zf3带有到一个模块中多个控制器的路由

时间:2017-11-12 19:58:35

标签: php model-view-controller controller routes zend-framework3

当我试图在一个模块中创建到多个控制器的路由时,我得到了this

sorted [] = Both
sorted [_] = Both
sorted (x:y:ys) | x > y = mappend rec Ascending
                | x < y = mappend rec Descending
                | otherwise = NotSorted
    where rec = sorted (y:ys)

致电 'application' => [ 'type' => Segment::class, 'options' => [ 'route' => '/application[/:action]', 'defaults' => [ 'controller' => Controller\IndexController::class, 'action' => 'index', ], ], ], 'vehicles' => [ 'type' => Segment::class, 'options' => [ 'route' => '/vehicles[/:action]', 'defaults' => [ 'controller' => Controller\VehiclesController::class, 'action' => 'index', ], ], ], 的{​​{1}}完美无缺。但它对indexAction()不起作用。我试图在IndexController中调用VehiclesController - 不成功。

VehiclesController

使用factories功能

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

1 个答案:

答案 0 :(得分:0)

您可能正在执行以下操作来调用key=value

中的控制器
module.config.php

因此,您可能在'controllers' => [ 'factories' => [ Controller\IndexController::class => InvokableFactory::class, Controller\IndexController::class => InvokableFactory::class, ], ], 键下两次使用相同的控制器名称。它可以是上述或不同的方式。

因此,在factories密钥的factories子项下定义它们一次,如下所示

controllers