How do I write a route in zf2 that allows for routes like /:controller/:action/*
in zf1?
So that it can cater for parameters like controller/action/id/1/page/2
and controller/action?id=1&page=2
?
A route that caters for parameters like controller/action?id=1&page=2
world be useful for ajax requests.
So my current code looks like this in my module.config.php
return array(
'controllers' => array(
'invokables' => array(
'Support\Controller\Support' => 'Support\Controller\SupportController',
),
),
'router' => array(
'routes' => array(
'support' => array(
'type' => 'segment',
'options' => array(
'route' => '/support[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Support\Controller\Support',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'support' => __DIR__ . '/../view',
),
),
A look at the docs for Zend\Mvc\Router and a quick root around in the module.config.php file for the Application module in the Zend Skeleton Application tell me that you need to set up a route segment router that will match the url's you want to create.
As well as the Zend Framework docs, there is this slide show introduction to routing in Zend Framework which you may find useful. It has code examples of what you want to achieve.
Take a look at the following question and answer:
How can you add query parameters in the ZF2 url view helper
I would attempt to set-up a route and then adding a child route that uses Zend\Mvc\Router\Http\Query
.