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. The key __NAMESPACE__
never works, and Zf2 tells that "resolves to invalid controller class or alias: 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).
How can I resolve the problem. I can't get some more info in zf site.
You shouldn't be needing '__NAMESPACE__' => 'Manager\\Controller\\Blog',
line of code.
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'
),
),
),
),
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.