我无法弄清楚在 zend 2 中从我想要的任何地方生成 Url
我得到了动作和控制器,所以我尝试这个:
$this->url('myControllerName', array('action' => 'myActionName'));
但这返回一个对象,我只想要该路由的完整 URL 字符串
有人可以帮助我找到正确的方法吗?
编辑:根据斯托扬的说法,也许我在路线上犯了一个错误。这是我的 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'
)
)
),
我的电话:
echo $this->url('indexqvm', array('action' => 'list-index'));
错误 :
可捕获的致命错误:Zend\Mvc\Controller\Plugin\Url 类的对象无法转换为字符串