在Zend框架3中,我尝试将新控制器“ArticleController”添加到现有模块City但失败了。我发布了屏幕截图,我的文件夹结构和module.config.php。你能解释一下问题是什么吗?顺便提一下,它在访问http://0.0.0.0:7000/city
时有效访问http://0.0.0.0:7000/article时
接下来,module \ city \ config \ module.config.php代码如下:
<?php
namespace City;
use Zend\Router\Http\Segment;
return [
'router' => [
'routes' => [
'city' => [
'type' => Segment::class,
'options' => [
'route' => '/city[/:action[/:id]]',
'constraints' => [
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
],
'defaults' => [
'controller' => Controller\CityController::class,
'action' => 'index',
],
],
],
'article' => [
'type' => Segment::class,
'options' => [
'route' => '/article[/:action[/:id]]',
'constraints' => [
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
],
'defaults' => [
'controller' => Controller\ArticleController::class,
'action' => 'index',
],
],
],
],
],
'view_manager' => [
'template_path_stack' => [
'city' => __DIR__ . '/../view',
],
],
];
答案 0 :(得分:2)
错误消息已清除。应用程序对您的控制器一无所知。您的模块配置必须包含有关“控制器”键下的控制器的信息。结账zend documentation,您将在配置文件中看到“控制器”键。