【发布时间】:2015-02-04 10:16:31
【问题描述】:
我正在为 Zend Framework 2 使用 ZfcUser 模块 在控制器文件夹中 控制器
--UserController.php
--EmployerController.php
在module.config.php中,我配置了路由
'router' => array(
'routes' => array(
'zfcuser' => array(
'type' => 'Literal',
'priority' => 1000,
'options' => array(
'route' => '/user',
'defaults' => array(
'controller' => 'zfcuser',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'employer' => array(
'type' => 'Literal',
'options' => array(
'route' => '/employer',
'defaults' => array(
'controller' => 'ZfcUser\Controller\Employer',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'edit' => array(
'type' => 'Segment',
'options' => array(
'route' => '/edit[/:id]',
'constraints' => array(
'id' => '[0-9]+'
),
'defaults' => array(
'controller' => 'ZfcUser\Controller\Employer',
'action' => 'edit'
)
),
),
),
),
),
),
),
),
当我运行链接时:domain.com/user/employer/edit/1
=> 错误:Route with name "edit" does not have child routes
=> 如何解决它
【问题讨论】:
-
在任何视图上试试这个:= $this->url('zfcuser/employer/edit') ?>它可能有助于调试
标签: php zend-framework routes zend-framework2 router