我是第一次设置 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';
}
}
以及在 module.config.php 中的违规路由 ( 'home'
):
<?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
]