ZF3骨架应用程序在更改模块时不起作用.Config.php应用程序模块



ZF3在更改应用模块

时无法正常工作

下载ZF3骨架应用程序,更改ZF3的路线

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

我将其更改为:

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

当我访问/test和/testapplication/index时,找不到404页的错误,似乎ZF3无法路由此路径

如果您安装了骨架应用并运行它而无需触摸任何东西,则问题是缓存。

如果您在应用程序配置文件(config/application.config.php(中查看,则会找到以下行:

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

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

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

最新更新