在我的模块command
中,我有类似的内容:
locals()
我想要实现的目标:
如何实现?
答案 0 :(得分:2)
尝试将文字更改为Zend\Mvc\Router\Http\Part
路由,然后将HTTP路由作为CHILD路由放入!
请参阅此处https://docs.zendframework.com/zend-router/routing/#http-route-types
答案 1 :(得分:2)
给自己和其他任何人看的一张纸条,作为@ delboy1978uk答案的附加说明。
我正在寻找的答案是这样的:
/index/foo
=> IndexController fooAction /index/foo
=> IndexController barAction 因此module.config.php
文件中的代码可以是这样的:
return [
//...
'myroute1' => [// The parent route will match the route "/index/foo"
'type' => Zend\Router\Http\Literal::class,
'options' => [
'route' => '/index/foo',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'foo',
],
],
'may_terminate' => false,
'child_routes' => [
'myroute1get' => [// This child route will match GET request
'type' => Method::class,
'options' => [
'verb' => 'get',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'foo'
],
],
],
'myroute1post' => [// This child route will match POST request
'type' => Method::class,
'options' => [
'verb' => 'post',
'defaults' => [
'controller' => Controller\IndexController::class,
'action' => 'bar'
],
],
]
],
],
//...
];