phpzend-frameworkzend-framework2zend-routezend-router

Zend Framework Routing - child route works but not main route


I have what I hope is quite a simple question, but it's been taking me a while to figure out...

I have tried to setup a /settings route in Zend. I do not have a module for settings but I have setup the necessary views and controllers within the application module.

I'll cut to the chase.

Here is my code:

        'settings' => array(
            'type' => 'literal',
            'options' => array(
                'route'    => '/settings',
                'defaults' => array(
                    'controller' => 'Application\Controller\Settings',
                    'action'     => 'index',
                ),
            ),
            'may_terminate' => true,
            'child_routes' => array(
                'default' => array(
                    'type'    => 'literal',
                    'options' => array(
                        'route'    => '/edit',
                        'defaults' => array(
                            'action'     => 'edit',
                        ),
                    ),
                ),
            ),
        ),

When I go to /settings/edit it shows the page correctly. If I enter /settings by itself I get a 404 "The requested URL could not be matched by routing."

Is there anything obvious in the syntax above?

Please ask if you need more info on code.

Thank you!


Solution

  • As @timfountain pointed out, was simply including a / on the route and this was breaking it... unbelievable simple/stupid.