How can I make the routing automatically work for everything in the ZF1 structure?
module/controller/action/par1Name/par1Val/par2Name/par2Val/
I read the information about routing, but the way I see it, I'd have to add all actions manually, and I see a problem with optional params...
You can set up a wildcard child_route, at least on a per-controller basis, to get zf1-like routes:
'products' => array(
'type' => 'Zend\Mvc\Router\Http\Segment',
'options' => array(
'route' => '/products[/:action]',
'defaults' => array(
'controller' => 'Application\Controller\Products',
'action' => 'index'
)
),
'may_terminate' => true,
'child_routes' => array(
'wildcard' => array(
'type' => 'Wildcard'
)
)
)
Then you can use, for instance, the url() view helper:
$this->url('products/wildcard',array('action'=>'edit','id'=>5,'foo'=>'bar');
which will produce a url like /products/edit/id/5/foo/bar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With