在zend 2中,我无法想出从我想要的任何地方生成Url
我得到动作和控制器所以我试试这个:
$this->url('myControllerName', array('action' => 'myActionName'));
Run Code Online (Sandbox Code Playgroud)
但是这会返回一个对象,我只想要这个路由的完整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'
)
)
),
Run Code Online (Sandbox Code Playgroud)
我的电话:
echo $this->url('indexqvm', array('action' => 'list-index'));
Run Code Online (Sandbox Code Playgroud)
错误:可捕获的致命错误:类Zend\Mvc\Controller\Plugin\Url的对象无法转换为字符串