php - '__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 configuration in module.config.php. key __namespace__
never works, , zf2 tells "resolves invalid controller class or alias: blog".
one other problem when not setting child_routes
, routematch can find right controller "manager\controller\index", when add context, routematch find other controller in other module(the index action of \application\controller\indexcontroller).
how can resolve problem. can't more info in zf site.
you shouldn't 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' ), ), ), ),
Comments
Post a Comment