I\'m currently using the ZendFrameworkSkeleton application from Git and am trying to utilize the module part of it to have a multitude of modules, changeable by URL like so:
To change routing you need to edit Application/confid/module.config.php. Find there and change to
'options' => array(
'route' => '/[:module/[:controller[/:action]]]',
'constraints' => array(
'module' => '[a-zA-Z][a-zA-Z0-9_-]*',
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*'
),
'defaults' => array(
'module' => 'Application',
'controller' => 'index',
'action' => 'index'
)
)
You can see I added /[:module and deafults and constraint
You can use 'child_routes' attribute in module.config.php file comes under module\Application\config
'routes' => array(
'application' => array(
'type' => 'Literal',
'options' => array(
'route' => '/application',
'defaults' => array(
'__NAMESPACE__' => 'Application\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
),
),
),
),
),
),
then you can run localhost/application/index/index
I found nice example on github https://github.com/akrabat/zf2-tutorial + pdf with explanation http://akrabat.com/wp-content/uploads/Getting-Started-with-Zend-Framework-2.pdf