[英]'__NAMESPACE__' in route config never work, and something wrong with child_routes in Zend Framework 2 (zf2)
return array(
'controllers' => array(
'invokables' => array(
'Manager\Controller\Index' => 'Manager\Controller\IndexController',
'Manager\Controller\Blog\Blog' => 'Manager\Controller\Blog\BlogController',
),
),
'router' => array(
'routes' => array(
'manager' => array(
'type' => 'Hostname',
'options' => array(
'route' => 'management.yfco.com',
'defaults' => array(
'__NAMESPACE__' => 'Manager\Controller',
'controller' => 'Index',
'action' => 'index',
)
),
'may_terminate' => TRUE,
'child_routes' => array(
'blog' => array(
'type' => 'Segment',
'options' => array(
'route' => '/blog[/:controller[/:action[/:id]]]',
'defaults' => array(
'__NAMESPACE__' => 'Manager\Controller\Blog',
'controller' => 'Blog',
'action' => 'index'
),
),
),
),
),
)
),
);
Above is my configuration in module.config.php. 上面是我在module.config.php中的配置。 The key
__NAMESPACE__
never works, and Zf2 tells that "resolves to invalid controller class or alias: Blog". 键
__NAMESPACE__
永不起作用,Zf2告知“解析为无效的控制器类或别名:Blog”。
One other problem is that when I am not setting the child_routes
, routeMatch can find the right Controller that is "Manager\\Controller\\Index", but when I add the context, routeMatch find other Controller in other module(the index action of \\Application\\Controller\\IndexController). 另一个问题是,当我未设置
child_routes
,routeMatch可以找到正确的Controller,即“ Manager \\ Controller \\ Index”,但是当我添加上下文时,routeMatch在其他模块中找到另一个Controller(\\ Application的index动作) \\控制器\\索引控制器)。
How can I resolve the problem. 我该如何解决该问题。 I can't get some more info in zf site.
我无法在zf网站上获得更多信息。
You shouldn't be needing '__NAMESPACE__' => 'Manager\\Controller\\Blog',
line of code. 您不应该需要
'__NAMESPACE__' => 'Manager\\Controller\\Blog',
行代码。
Just try 你试一试
'may_terminate' => TRUE,
'child_routes' => array(
'blog' => array(
'type' => 'Segment',
'options' => array(
'route' => '/blog[/:controller[/:action[/:id]]]',
'defaults' => array(
'controller' => 'Blog',
'action' => 'index'
),
),
),
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.