我正在尝试使用子段创建路由示例:/account/:accountId/user/edit/:userId
模块.config.php:
'router' => array(
'routes' => array(
'account' => array(
'type' => 'segment',
'options' => array(
'route' => '/account/:accountid',
'constraints' => array(
'accountid' => '[a-z0-9_-]*',
),
'defaults' => array(
'controller' => 'My\Controller\Account',
'action' => 'index',
),
'may_terminate' => true,
'child_routes' => array(
'user' => array(
'type' => 'segment',
'options' => array(
'route' => '/user/edit/:userid',
'constraints' => array(
'userid' => '[a-z0-9_-]*',
),
'defaults' => array(
'action' => 'edit'
)
),
)
)
),
),
当我打电话时:
<?= $this->url('account/user', ['accountid' => 'foo', 'userid' => 'bar']);
我只得到: /account/foo 我想要的地方 /account/foo/user/edit/bar
我确实尝试将 may_terminate 更改为 false 而没有更改