【发布时间】:2014-03-27 14:20:06
【问题描述】:
我使用了 zend 骨架应用程序,但是当我路由我的模块时,它给出了错误发生 404 错误 找不到网页。 请求的 URL 无法通过路由匹配。 这是我的 module.config.php 文件代码:
<?php
return array(
'controllers' => array(
'invokables' => array(
'Calendar\Controller\Calendar' => 'Calendar\Controller\CalendarController',
'Calendar\Controller\Event' => 'Calendar\Controller\EventController',
),
),
'router' => array(
'routes' => array(
'calendar' => array(
'type' => 'segment',
'options' => array(
'route' => '/calendar[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Calendar\Controller\Calendar',
'action' => 'index',
),
),
),
'event' => array(
'type' => 'segment',
'options' => array(
'route' => '/event[/:action][/:id][/:unixTime][/:allDay]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
'unixTime' => '[0-9]+',
'allDay' => '0|1',
),
'defaults' => array(
'controller' => 'Calendar\Controller\Event',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'calendar' => __DIR__ . '/../view',
),
),
);
如何在 zf2 中设置路由?
【问题讨论】:
-
你的路由无论如何都不能被路由匹配。您有两个具有相同约束的可选参数,路由器将无法知道是哪个参数。
标签: php zend-framework2