MGP*_*MGP 3 zend-route zend-framework2
我在设置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',
),
),
),
),
),
),
),
Run Code Online (Sandbox Code Playgroud)
但它只能这样工作:
'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',
),
),
),
'app.example' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '[/:info]/app/example[/:data]',
'defaults' => array(
'__NAMESPACE__' => 'X\App',
'controller' => 'Index',
'action' => 'example',
),
),
),
),
Run Code Online (Sandbox Code Playgroud)
..谁都知道我可能做错了什么..?
你的孩子路线在错误的地方,他们不属于options阵列,也不属于may_terminate key,试试这个......
'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',
),
),
),
),
),
),
),
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5892 次 |
| 最近记录: |