In ZF2, you include the variable name in the pattern match, so you want something like this:
'regex' => '(?<full_path>.*)/(?<nodeID>[0-9]+).htm',
Then your code should work.
Question
I have following route defined
'kategoria' => array(
'type' => 'Zend\Mvc\Router\Http\Regex',
'options' => array(
'regex' => '(.*)/([0-9]+).htm',
'defaults' => array(
'controller' => 'Core\Controller\Index',
'action' => 'index'
),
'spec' => '%full_path%/%nodeID%.htm',
),
),
I'm trying to get both params in action, but no success
$nodeID = $this->params()->fromRoute('nodeID');
$full_path = $this->params('full_path','');
How to get matched params from Regex router in ZF2 ? I'm using this router in ZF1.
Solution
In ZF2, you include the variable name in the pattern match, so you want something like this:
'regex' => '(?<full_path>.*)/(?<nodeID>[0-9]+).htm',
Then your code should work.