Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Url view helper gives urls that doesn't work when using index as action #2503

zfbot opened this Issue · 5 comments

4 participants


Jira Information

Original Issue: ZF2-407
Issue Type: Bug
Reporter: Mats Svensson
Created: 07/18/12
Assignee: DASPRiD
Components: Zend\Mvc\Router


Or it may be the other way around, that these routes should work but doesn't. Anyhow, there is a mismatch between the view helper and the route resolver.
See my SO post here, where I encounter the issue:

I have a route like this:

'xmlcoverage' => array(
        'type'    => 'segment',
        'options' => array(
                'route' => '/xml/coverage[/:action][/:id]',
                'constraints' => array(
                        'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                        'id'     => '[0-9]+',
                'defaults' => array(
                        'controller' => 'modulename/xmlcoverage',
                        'action'     => 'index',

I use the url view helper like this:

$this->url('xmlcoverage', array('action' => 'index', 'id' => $someid))

This gives me xml/coverage/33 which crashes. "The requested controller was unable to dispatch the request."
I believe an id after the controller should map to index action, but it does not. But if it does not, at least the url helper
should make the url work, like xml/coverage/index/33


This issue was ported from the ZF2 Jira Issue Tracker at

Known GitHub users mentioned in the original message or comment:


I went around this issue with
public function notFoundAction()
$view = new ViewModel($this->indexAction());
return $view;

However, I'm no longer experiencing this issue.


Thanks @Matsemann


Then you should provide a non-working example in a new issue or this one (and if this one, reopen it).


Comment removed, what I responded to:

I'm facing the same bug it is not fixed yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.