Skip to content

Instantly share code, notes, and snippets.

@settermjd
Created April 2, 2014 14:37
Show Gist options
  • Save settermjd/9935478 to your computer and use it in GitHub Desktop.
Save settermjd/9935478 to your computer and use it in GitHub Desktop.
Simple example of using child routes, using the Segment type, to keep a routing table in Zend Framework 2 simple and compact. For more information, check out http://www.masterzendframework.com/tutorial/child-and-segment-routes.
return array(
'router' => array(
'routes' => array(
'forecaster' => array(
'type' => 'Literal',
'options' => array(
'route' => '/forecaster',
'defaults' => array(
'__NAMESPACE__' => 'Forecaster\Controller',
'controller' => 'Forecaster',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'earnings-period' => array(
'type' => 'segment',
'options' => array(
'route' => '/earnings/[:period]/[:type]',
'constraints' => array(
'period' => '(this|previous|last|next|current)',
'type' => '(week|month|quarter|year)'
),
'defaults' => array(
'controller' => 'earnings',
'action' => 'view'
)
)
),
'pipeline-period' => array(
'type' => 'segment',
'options' => array(
'route' => '/pipeline/[:period]/[:type]',
'constraints' => array(
'period' => '(this|previous|last|next|current)',
'type' => '(week|month|quarter|year)'
),
'defaults' => array(
'controller' => 'pipeline',
'action' => 'view'
)
)
),
),
),
),
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment