I can't figure out how to generate Url everywhere I want in zend 2
I get the action and controller, so I try this:
$this->url('myControllerName', array('action' => 'myActionName'));
But this returns an object, I just want the full URL string of this route
Can anyone help me find the right way?
EDIT: According to Stoyan, maybe I was wrong on my route. here is part of my module.config
'router' => array ( 'routes' => array ( 'indexqvm' => array ( 'type' => 'segment', 'options' => array ( 'route' => '/Indexqvm[/:action][/:id_event]', 'constraints' => array ( 'action' => '[a-zA-Z][a-zA-Z0-9_-]+', 'id_event' => '[0-9]+' ), 'defaults' => array ( 'controller' => 'Qvm\Controller\Indexqvm', 'action' => 'index' ) ) ),
And my call:
echo $this->url('indexqvm', array('action' => 'list-index'));
error: Catchable fatal error: Object of class Zend \ Mvc \ Controller \ Plugin \ Url cannot be converted to a string
url php zend-framework2 action
Reign. 85
source share