Php 错误配置路由在zend framework 2中没有子路由?
我正在为Zend Framework 2使用ZfcUser模块 在控制器文件夹中 控制器Php 错误配置路由在zend framework 2中没有子路由?,php,zend-framework,routes,zend-framework2,router,Php,Zend Framework,Routes,Zend Framework2,Router,我正在为Zend Framework 2使用ZfcUser模块 在控制器文件夹中 控制器 --UserController.php --EmployerController.php 在module.config.php中,我使用route进行配置 'router' => array( 'routes' => array( 'zfcuser' => array( 'type' => 'Literal',
--UserController.php
--EmployerController.php
在module.config.php中,我使用route进行配置
'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
=>错误:名为“edit”的路由没有子路由
=>如何修复它我认为您不需要在路由配置中添加
编辑
作为子路由。如果我正确理解您的案例,edit
是一个操作
,因此您可以将其作为选项添加到雇主
路线中,如下所示:
'router' => array(
'routes' => array(
'zfcuser' => array(
'type' => 'Literal',
'options' => array(
'route' => '/user',
'defaults' => array(
'controller' => 'zfcuser',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'employer' => array(
'type' => 'segment',
'options' => array(
'route' => '/employer/[:action[/:id]]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id'=>'[0-9]+'),
'defaults' => array(
'controller' => 'ZfcUser\Controller\Employer',
'action' => 'index',
)
),
),
),
),
),
),
希望这能有所帮助 我认为您不需要在路由配置中添加
编辑
作为子路由。如果我正确理解您的案例,edit
是一个操作
,因此您可以将其作为选项添加到雇主
路线中,如下所示:
'router' => array(
'routes' => array(
'zfcuser' => array(
'type' => 'Literal',
'options' => array(
'route' => '/user',
'defaults' => array(
'controller' => 'zfcuser',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'employer' => array(
'type' => 'segment',
'options' => array(
'route' => '/employer/[:action[/:id]]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id'=>'[0-9]+'),
'defaults' => array(
'controller' => 'ZfcUser\Controller\Employer',
'action' => 'index',
)
),
),
),
),
),
),
希望这能有所帮助 我认为您不需要在路由配置中添加
编辑
作为子路由。如果我正确理解您的案例,edit
是一个操作
,因此您可以将其作为选项添加到雇主
路线中,如下所示:
'router' => array(
'routes' => array(
'zfcuser' => array(
'type' => 'Literal',
'options' => array(
'route' => '/user',
'defaults' => array(
'controller' => 'zfcuser',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'employer' => array(
'type' => 'segment',
'options' => array(
'route' => '/employer/[:action[/:id]]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id'=>'[0-9]+'),
'defaults' => array(
'controller' => 'ZfcUser\Controller\Employer',
'action' => 'index',
)
),
),
),
),
),
),
希望这能有所帮助 我认为您不需要在路由配置中添加
编辑
作为子路由。如果我正确理解您的案例,edit
是一个操作
,因此您可以将其作为选项添加到雇主
路线中,如下所示:
'router' => array(
'routes' => array(
'zfcuser' => array(
'type' => 'Literal',
'options' => array(
'route' => '/user',
'defaults' => array(
'controller' => 'zfcuser',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'employer' => array(
'type' => 'segment',
'options' => array(
'route' => '/employer/[:action[/:id]]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id'=>'[0-9]+'),
'defaults' => array(
'controller' => 'ZfcUser\Controller\Employer',
'action' => 'index',
)
),
),
),
),
),
),
希望这能有所帮助 由
可终止
和子路由
索引的数组应移动到雇主
由可终止
和子路由
索引的数组应移动到雇主
由可终止
和子路由
索引的数组应移动到雇主
中移动到雇主
由索引的数组可以终止
和子路由
应该移动到雇主
在任何视图上尝试此操作:它可能有助于调试在任何视图上尝试此操作:它可能有助于调试在任何视图上尝试此操作:它可能有助于调试在任何视图上尝试此操作:它可能有助于调试