zend-framework2 – ZF2子路由问题

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了zend-framework2 – ZF2子路由问题脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我在设置child_routes方面遇到了一些麻烦.
除非我把它们分开,否则它们不起作用,最终结果应该是相同的!:

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

'router' => array(
        'routes' => array(
            'app' => array(
                'tyPE' => 'Zend\Mvc\Router\Http\Segment','options' => array(
                    'route' => '[/:info]/app','defaults' => array(
                        '__namesPACE__' => 'X\App','controller' => 'Index','action' => 'index',),'may_terminate' => true,'child_routes' => array(
                        'example' => array(
                            'type' => 'Zend\Mvc\Router\Http\Segment','options' => array(
                                'route' => '/example[:/data]','defaults' => array(
                                    'action' => 'example',

但它只能这样工作:

'router' => array(
        'routes' => array(
            'app' => array(
                'type' => 'Zend\Mvc\Router\Http\Segment','app.example' => array(
                'type' => 'Zend\Mvc\Router\Http\Segment','options' => array(
                    'route' => '[/:info]/app/example[/:data]','action' => 'example',

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

解决方法

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

'router' => array(
    'routes' => array(
        'app' => array(
            'type' => 'Zend\Mvc\Router\Http\Segment','options' => array(
                'route' => '[/:info]/app','defaults' => array(
                    '__NAMESPACE__' => 'X\App','child_routes' => array(
                'example' => array(
                    'type' => 'Zend\Mvc\Router\Http\Segment','options' => array(
                        'route' => '/example[:/data]','defaults' => array(
                            'action' => 'example',

脚本宝典总结

以上是脚本宝典为你收集整理的zend-framework2 – ZF2子路由问题全部内容,希望文章能够帮你解决zend-framework2 – ZF2子路由问题所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。