Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 错误配置路由在zend framework 2中没有子路由?_Php_Zend Framework_Routes_Zend Framework2_Router - Fatal编程技术网

Php 错误配置路由在zend framework 2中没有子路由?

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',

我正在为Zend Framework 2使用ZfcUser模块 在控制器文件夹中 控制器

--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',
                         )
                ),
            ),
        ),
    ),
),
),

希望这能有所帮助

可终止
子路由
索引的数组应移动到
雇主
可终止
子路由
索引的数组应移动到
雇主
可终止
子路由
索引的数组应移动到
雇主
中移动到
雇主

索引的数组可以终止
子路由
应该移动到
雇主

在任何视图上尝试此操作:它可能有助于调试在任何视图上尝试此操作:它可能有助于调试在任何视图上尝试此操作:它可能有助于调试在任何视图上尝试此操作:它可能有助于调试