更改 module.config.php 应用程序模块时 zf3 骨架应用程序无法正常工作

zf3 skeleton application not working when change module.config.php of Application module

zf3 在更改应用程序模块的路由时无法正常工作

下载一个zf3骨架应用,改变zf3的路由

'router' => [
    'routes' => [
        'home' => [
            'type' => Literal::class,
            'options' => [
                'route'    => '/',
                'defaults' => [
                    'controller' => Controller\IndexController::class,
                    'action'     => 'index',
                ],
            ],
        ],
        'application' => [
            'type'    => Segment::class,
            'options' => [
                'route'    => '/application[/:action]',
                'defaults' => [
                    'controller' => Controller\IndexController::class,
                    'action'     => 'index',
                ],
            ],
        ],
    ],
],

我改成:

'router' => [
    'routes' => [
        'home' => [
            'type' => Literal::class,
            'options' => [
                'route'    => '/test',
                'defaults' => [
                    'controller' => Controller\IndexController::class,
                    'action'     => 'index',
                ],
            ],
        ],
        'application' => [
            'type'    => Segment::class,
            'options' => [
                'route'    => '/testapplication[/:action]',
                'defaults' => [
                    'controller' => Controller\IndexController::class,
                    'action'     => 'index',
                ],
            ],
        ],
    ],
],

当我访问 /test 和 /testapplication/index 时,出现 404 页面未找到错误,似乎 zf3 无法路由到此路径

如果您安装了框架应用程序并且 运行 它没有接触任何东西,那么问题就是缓存。

如果您查看应用程序配置文件 (config/application.config.php),您会发现这些行:

return [
    'module_listener_options' => [
        // Line 33
        'config_cache_enabled' => true
    ]
];

这将在缓存目录下创建一个缓存文件(默认情况下,data/cache,如第 47 行 application.config.php 中所定义)。

出于开发目的,我建议您禁用缓存。最好的方法是从 config/development.config.php.dist 配置文件中删除 .dist