如何在 zf2 中编写允许类似/:controller/:action/*
zf1 的路由的路由?
这样它就可以满足controller/action/id/1/page/2
和controller/action?id=1&page=2
?
满足诸如controller/action?id=1&page=2
world 之类的参数的路由对于 ajax 请求很有用。
所以我当前的代码在我的module.config.php中看起来像这样
return array(
'controllers' => array(
'invokables' => array(
'Support\Controller\Support' => 'Support\Controller\SupportController',
),
),
'router' => array(
'routes' => array(
'support' => array(
'type' => 'segment',
'options' => array(
'route' => '/support[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Support\Controller\Support',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'support' => __DIR__ . '/../view',
),
),