Skip to content

Instantly share code, notes, and snippets.

@Sylyac2000
Forked from settermjd/compact-child-routes
Created May 28, 2019 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sylyac2000/c96f2c410b9e34ff338d14392a1d93b0 to your computer and use it in GitHub Desktop.
Save Sylyac2000/c96f2c410b9e34ff338d14392a1d93b0 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