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 force
或 php public/index.php remove
我从来没有被派去做控制器,也没有错误或任何输出。那我是不是匹配错了?
好像应用没有意识到它是从终端调用的。如果我从 module/MyModulefolder
.
中的 Module.php
中删除 getConfig
方法,有时它只是 returns html
问题是我没有在 modules.config.php
中包含 'Zend\Mvc\Console'
,所以当它从控制台收到命令时它没有反应。
将其放入 modules.config.php
中的数组后,一切正常。
菜鸟错误。
我的 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 force
或 php public/index.php remove
我从来没有被派去做控制器,也没有错误或任何输出。那我是不是匹配错了?
好像应用没有意识到它是从终端调用的。如果我从 module/MyModulefolder
.
Module.php
中删除 getConfig
方法,有时它只是 returns html
问题是我没有在 modules.config.php
中包含 'Zend\Mvc\Console'
,所以当它从控制台收到命令时它没有反应。
将其放入 modules.config.php
中的数组后,一切正常。
菜鸟错误。