代码之家  ›  专栏  ›  技术社区  ›  hikozuma

向zf3中的现有模块添加新控制器

  •  0
  • hikozuma  · 技术社区  · 7 年前

    在Zend framework 3中,我尝试将新控制器“ArticleController”添加到现有的模块城市中,但失败了。我张贴屏幕截图,我的文件夹结构和模块。配置。php。你能解释一下问题是什么吗?顺便说一句,当访问 http://0.0.0.0:7000/city

    http://0.0.0.0:7000/article enter image description here enter image description here

    <?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',
            ],
        ],
    ];  
    
    1 回复  |  直到 7 年前
        1
  •  2
  •   Mehmet SÖĞÜNMEZ    7 年前

    zend documentation ,您将在配置文件中看到“controllers”键。