php - Why is my ZF2 Segment child route being ignored? -


i have following routing config in project:

'router' => array(     'routes' => array(         'home' => array(             'type' => 'zend\mvc\router\http\literal',             'options' => array(                 'route' => '/',                 'defaults' => array(                     '__namespace__' => 'myapp\controller',                     'controller' => 'default',                     'action' => 'default',                 ),             ),             'may_terminate' => true,             'child_routes' => array(                 'api' => array(                     'type' => 'zend\mvc\router\http\segment',                     'options' => array(                         'route' => 'api/:action[/:id]',                         'defaults' => array(                             '__namespace__' => 'myapp\controller',                             'controller' => 'api',                             'action' => 'index',                         ),                     ),                     'may_terminate' => true,                 ),                 'default' => array(                     'type' => 'zend\mvc\router\http\segment',                     'options' => array(                         'route' => '[:id]',                         'defaults' => array(                             '__namespace__' => 'myapp\controller',                             'controller' => 'default',                             'action' => 'default',                         ),                     ),                     'may_terminate' => true,                 ),             ),         ),     ), ), 

when make call http://localhost/api/foo/bar response defaultcontroller. have stripped application until route (removed home/default, , made route application) ignored.

the desired outcome calls /api... go api controller, other calls go default controller.

there no errors being thrown far can see (looking @ apache2 logs)

any suggestions might wrong?

i think it's because default route id has no constraints, it's matching everything. try adding after default route.

'constraints' => ['id' => '[0-9]'],


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -