【发布时间】:2020-11-30 04:28:14
【问题描述】:
我是第一次设置 ZF3 项目,但我似乎无法让路由正常工作。在我的主页上,我收到 404:“请求的 URL 无法通过路由匹配。”
这是我的目录结构:
我的模块.php:
<?php
namespace Home;
use Laminas\ModuleManager\Feature\AutoloaderProviderInterface;
use Laminas\ModuleManager\Feature\ConfigProviderInterface;
class Module implements AutoloaderProviderInterface, ConfigProviderInterface
{
public function getAutoloaderConfig()
{
return [
'Zend\Loader\StandardAutoloader' => [
'namespaces' => [
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
],
],
];
}
public function getConfig()
{
return include __DIR__ . '/../config/module.config.php';
}
}
还有违规路由 ('home'),在 module.config.php 中:
<?php
namespace Home;
return [
'router' => [
'routes' => [
'home' => [
'type' => 'Literal',
'options' => [
'route' => '/',
'defaults' => [
'controller' => Controller\SkeletonController::class,
'action' => 'index',
],
],
'may_terminate' => true,
'child_routes' => [
// You can place additional routes that match under the
// route defined above here.
],
],
],
],
... // Other stuff
]
【问题讨论】:
-
您是否检查过缓存是否启用?如果是这样,请禁用它(或删除它)并重试;)
-
那会是由
'config_cache_enabled'键入的application.config.php 中的值吗?我只是将其设置为 false 并且没有任何更改
标签: routes http-status-code-404 url-routing zend-framework3 laminas