ZF3多模块中的相同控制器名称和别名

时间:2018-09-28 07:39:24

标签: module controller zend-framework3

你好,我有一个Zf3项目。

我有多个具有相同控制器名称和别名的模块

我的目标

localhost/cart/index
localhost/user/index

但是

localhost/user/index

始终转到模块购物车indexController 如何解决这个问题

1.module购物车

'controllers' => [
    Controller\IndexController::class => InvokableFactory::class],
    'aliases'=>[
        'index' => Controller\IndexController::class ,
    ],
],

'router' => [
    'routes' => [
    'cart' => [
            'type'    => Segment::class,
            'options' => [
                'route'    => '/cart[/:controller[/:action]]',
                'defaults' => [
                    'controller' => Controller\IndexController::class,
                    'action'     => 'index',
                ],
            ],
        ]
    ]
]

2.module用户

'controllers' => [
    Controller\IndexController::class => InvokableFactory::class],
    'aliases'=>[
        'index' => Controller\IndexController::class ,
    ],
],

'router' => [
    'routes' => [
    'user' => [
            'type'    => Segment::class,
            'options' => [
                'route'    => '/user[/:controller[/:action]]',
                'defaults' => [
                    'controller' => Controller\IndexController::class,
                    'action'     => 'index',
                ],
            ],
        ]
    ]
]

0 个答案:

没有答案