更改应用程序模块的module.config.php时,zf3骨架应用程序无法正常工作 [英] zf3 skeleton application not working when change module.config.php of Application module

查看:116
本文介绍了更改应用程序模块的module.config.php时,zf3骨架应用程序无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

zf3 not work well when change route of Appliation module

下载zf3骨架应用程序,更改zf3的路由

download a zf3 skeleton application ,change route of 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无法路由到该路径

when i visit /test and /testapplication/index , i got 404 page not found error, it seems zf3 can't route to this path

推荐答案

如果您安装了框架应用程序并在不触摸任何内容的情况下运行它,那么问题就出在缓存上.

If you installed the skeleton app and run it without touching anything, then the problem is the cache.

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

If you look in the application config file (config/application.config.php), you will find these lines:

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

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

This will create a cache file under the cache directory (by default, data/cache, as defined in application.config.php at line 47).

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

For development purposes, I suggest you to disable the cache. The best way to do that is to remove the .dist from the config/development.config.php.dist configuration file.

这篇关于更改应用程序模块的module.config.php时,zf3骨架应用程序无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆