zf3 not work well when change route of Appliation module
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',
],
],
],
],
],
I change it to :
'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',
],
],
],
],
],
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.
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
]
];
This will create a cache file under the cache directory (by default, data/cache
, as defined in application.config.php
at line 47).
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.