我正在尝试使用 zend 控制台并遵循他们网站上的文档。这是我的代码。
模块.config.php
"router" => [
"routes" => [
"companies" => [
"type" => "segment",
"options" => [
"route" => "/companies[/:action[/:id]]",
"constraints" => [
"action" => "[a-zA-Z][a-zA-Z0-9_-]*",
"id" => "[0-9]*",
],
"defaults" => [
"controller" => Controller\CompaniesController::class,
"action" => "index",
],
],
],
],
],
"console" => [
"router" => [
"routes" => [
"abc1" => [
"options" => [
"route" => "abc1",
"defaults" => [
"controller" => Controller\Console::class,
"action" => "abc",
],
],
],
],
],
],
我的控制器
public function abcAction() {
$request = $this->getRequest();
if (! $request instanceof ConsoleRequest) {
throw new RuntimeException("You can only use this action from a console!");
}
return "Done! abc.\n";
}
当我这样做php public/index.php abc1
时,它什么也不做。什么都不显示。我是否缺少任何配置?