Zend3中的控制台路由不匹配


Console route in Zend3 is not matching

我在module.config.php文件中有一个控制台路由

'console' => [
        'router' => [
            'routes' => [
                'remove' => [
                    'type'    => 'simple',
                    'options' => [
                        'route'    => 'remove [force] [init]',
                        'defaults' => [
                            'controller' => Controller'CliController::class,
                            'action'     => 'remove',
                        ],
                    ],
                ]
            ]
        ]
    ]

我的控制器有方法removeAction()

namespace Controller;
class CliController extends AbstractActionController
{
    public function removeAction()
    {
        $this->logger->debug('I am in');
    }
}

当我执行php public/index.php remove forcephp public/index.php remove命令时我从来没有被发送到控制器,也没有错误或任何输出。那么我是否做错了匹配?

这就像应用程序没有意识到它是从终端调用的。有时它只是返回html,如果我从module/MyModulefolder中的Module.php中删除getConfig方法。

问题是我没有在modules.config.php中包括'Zend'Mvc'Console',所以当它从控制台得到命令时,它没有反应。

modules.config.php中放入数组后,一切都正常了。

新手的错误。