加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

zend-framework2 – ZF2子路由问题

发布时间:2020-12-13 21:47:11 所属栏目:PHP教程 来源:网络整理
导读:我在设置child_routes方面遇到了一些麻烦. 除非我把它们分开,否则它们不起作用,最终结果应该是相同的!: 这就是我想要实现的目标: 'router' = array( 'routes' = array( 'app' = array( 'type' = 'ZendMvcRouterHttpSegment','options' = array( 'rout
我在设置child_routes方面遇到了一些麻烦.
除非我把它们分开,否则它们不起作用,最终结果应该是相同的!:

这就是我想要实现的目标:

'router' => array(
        'routes' => array(
            'app' => array(
                'type' => 'ZendMvcRouterHttpSegment','options' => array(
                    'route' => '[/:info]/app','defaults' => array(
                        '__NAMESPACE__' => 'XApp','controller' => 'Index','action' => 'index',),'may_terminate' => true,'child_routes' => array(
                        'example' => array(
                            'type' => 'ZendMvcRouterHttpSegment','options' => array(
                                'route' => '/example[:/data]','defaults' => array(
                                    'action' => 'example',

但它只能这样工作:

'router' => array(
        'routes' => array(
            'app' => array(
                'type' => 'ZendMvcRouterHttpSegment','app.example' => array(
                'type' => 'ZendMvcRouterHttpSegment','options' => array(
                    'route' => '[/:info]/app/example[/:data]','action' => 'example',

..谁都知道我可能做错了什么..?

解决方法

你的子路由在错误的地方,它们不属于options数组,may_terminate键也没有,试试这个……

'router' => array(
    'routes' => array(
        'app' => array(
            'type' => 'ZendMvcRouterHttpSegment','options' => array(
                'route' => '[/:info]/app','defaults' => array(
                    '__NAMESPACE__' => 'XApp','child_routes' => array(
                'example' => array(
                    'type' => 'ZendMvcRouterHttpSegment','options' => array(
                        'route' => '/example[:/data]','defaults' => array(
                            'action' => 'example',

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读