'__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. 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.

Answers


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'
            ),
        ),
    ),
),

Need Your Help

Two way UDP sockets in C

c sockets client-server

This is a very basic question on UDP sockets. I myself have programmed some server/client application using them, but I'm stuck now and not able to see where the problem is.