我是ZF2的乞讨。我尝试做路由器,当我在View中使用时。我有这个错误: 致命错误:未捕获的异常'Zend \ Mvc \ Router \ Exception \ RuntimeException',消息'Route with name'文档“找不到”
你能帮助我吗?
这是我的代码:
<?php
return array(
'controllers' => array(
'invokables' => array(
'Documents\Controller\Documents' => 'Documents\Controller\DocumentsController',
),
),
'router' => array(
'routes' => array(
'documents' => array(
'type' => 'segment',
'options' => array(
'route' => '/DocumentsController[/:action]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'__NAMESPACE__' => 'Documents\Controller',
'controller' => 'Documents\Controller\DocumentsController',
'action' => 'add',
),
)
)
)
)
);
由于
答案 0 :(得分:0)
&#39;路线&#39;您定义的名称是&#39;文档&#39;
尝试更改以下行
'route' => '/DocumentsController[/:action]',
与
'route' => '/documents[/:action]',
同样在视图文件中,将url创建为 -
例如:
<?php echo $this->url('documents', array('action' => 'index')); ?>